Finding index number of a column in a csv file, but command doesnt show result?
Could you please try following, written and tested with shown samples only.
awk 'BEGIN{ FS=";"}{ gsub(/\r/,"") for(i=1;i<=NF;i++){ if($i=="Deceased"){ print "Index is:"i exit } }}' Input_file
OR in case your string could be anything then you could create an awk
variable named strSearch
and could assign its value as per your string which you want to look for its index.
awk -v strSearch="Deceased" 'BEGIN{ FS=";"}{ gsub(/\r/,"") for(i=1;i<=NF;i++){ if($i==strSearch){ print "Index is:"i exit } }}' Input_file
Output will be as follows.
Index is:7