FANDOM


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 onlyEdit

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

Filtering by the third column, obtain the whole rowEdit

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 rowEdit

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 rowEdit

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


NotesEdit

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

See also Edit

How to know column headers positions

Community content is available under CC-BY-SA unless otherwise noted.