Unix Wiki
Advertisement

You have file comma separated values. You need certain rows where a(some) specific column(s) has some value.

Filtering by the third column, obtain that column only[]

awk -F',' '($3 ~ "VALUE") {print $3}' File.csv

Filtering by the third column, obtain the whole row[]

awk -F',' '($3 ~ "VALUE") {print $0}' File.csv

Filtering by the second column, looking for all rows in which the second column starts with "XA", obtain the whole row[]

awk -F',' '($2 ~ "^XA") {print $0}' File.csv

Filtering by the second column, looking for all rows in which the second column contains exactly "XA", obtain the whole row[]

awk -F',' '($2 ~ "^XA$") {print $0}' File.csv


Notes[]

  • On Solaris, use nawk instead of awk. On some other systems, you might want to use gawk instead.

See also[]

How to know column headers positions

Advertisement