Friday, July 31, 2009

Awk Command in Linux

awk is a very useful command. I would document some very simple but useful example here. As a rule of thumb: we use "condition {expression}" in awk.

#Extract first column while the lines are comma seperated

awk '{FS=","}{print $1}'


#Check whether second column is "Artists", if so, print first and second columns.

awk '{FS="\t"} $2 = "Artists" {print $1 "\t" $2}'

No comments:

Post a Comment