I have this input with null values in it in a tab separated csv file.I wanna check if a value is e.g., >= 800 or not and add the result to a new column.
input
a
623
616
803
output
a b
623 no
no
616 no
803 yes
awk -v minval=800 'BEGIN{ FS=OFS="\t" }
FNR==1{ print $0, "b"; next } # print header
{ print $0, ($1 >= minval ? "yes" : "no") }
' file
Output:
a b
623 no
no
616 no
803 yes
You don't need an explicit check if the first column is empty. If you compare a string to a number, the number is converted to a string. And the empty string always comes before any non-empty string when compared lexicographically, thus it is never greater or equal to a non-empty string.