Sorry if this is too basic. I have a csv file where the columns have a header row (v1, v2, etc.). I understand that to extract columns 1 and 2, I have to do: awk -F \
Others have answered your earlier question. For this:
As an addendum, is there any way to extract directly with the header names rather than with column numbers?
I haven't tried it, but you could store each header's index in a hash and then use that hash to get its index later on.
for(i=0;i<$NF;i++){
hash[$i] = i;
}
Then later on, use it:
j = hash["header1"];
print $j;