data.csv is the input file
eid,ename,esal
101,Raju,8000
106,Sanjay,5000
109,Anjali,4000
awk '$esal > 5000 { print $esal }' data.csv
the above is the command which i have tried. the output is:
eid,ename,esal
567,pinky,4000
Expected output is:
eid,ename,esal
101,Raju,8000
CodePudding user response:
You can do something like this if you want to address columns by name:
awk 'BEGIN{FS=OFS=","}
FNR==1{
for(i=1;i<=NF;i ) {
header[$i]=i
printf("%s%s", $i, i==NF ? ORS : OFS)
}
next
}
$header["esal"]>5000
' file
Prints:
eid,ename,esal
101,Raju,8000
CodePudding user response:
$ awk -F, 'NR==1 || $NF>5000' file