1

awk command to print only selected rows in a particular column specified by column name

view story
linux-howto

http://www.unix.com – Dear All, I have a data file input.csv like below. (Only five column shown here for example.) Code: Data1,StepNo,Data2,Data3,Data4 2,1,3,4,5 3,1,5,6,7 3,2,4,5,6 5,3,5,5,6 From this I want the below output Code: Data1,StepNo,Data2,Data3,Data4 2,1,3,4,5 3,1,5,6,7 where the second column StepNo contents are '1'. I used the below simple script to get this output. Code: awk -F, '$2==1' input.csv But many times the second column is not always StepNo as there are many versions of input files with varying column positions and total number of columns. So I need a script(with awk) (HowTos)