I am not sure about what you mean by cat the value of c1 c2 c3 c4 c5 and c9
however if want you want is to filter only those columns, then you can use the following awk
command:
awk 'BEGIN{OFS=FS=","}{print $1,$2,$3,$4,$5,$9}' sample.csv
INPUT:
more sample.csv
c1,c2,c3,c4,c5,c6,c7,c8,c9
123,B006195,T,O,INDIVIDUAL,25^5820200^,2018-04-25,13,NEW
12,C06195,T,O,INDIVIDUAL,25^5820200^,2018-04-25,13,NEW
12345,B00619,T,O,IND,25^5820200^,2018-04-25,13,OLD
OUTPUT:
awk 'BEGIN{OFS=FS=","}{print $1,$2,$3,$4,$5,$9}' sample.csv
c1,c2,c3,c4,c5,c9
123,B006195,T,O,INDIVIDUAL,NEW
12,C06195,T,O,INDIVIDUAL,NEW
12345,B00619,T,O,IND,OLD
Explanations:
You define as field separator (input,output) a ,
(BEGIN{OFS=FS=","}
) then you just print for each line the columns that you need to display {print $1,$2,$3,$4,$5,$9}
after you redirect the output to a new csv file
If you think that awk
is an overkill for this task than you can also just use the cut
command (-d','
is to define a ,
as delimiter and -f...
is to specify which field need to be kept):
$ cut -d',' -f1,2,3,4,5,9 sample.csv
c1,c2,c3,c4,c5,c9
123,B006195,T,O,INDIVIDUAL,NEW
12,C06195,T,O,INDIVIDUAL,NEW
12345,B00619,T,O,IND,OLD