Linux command: awk

From RHS Wiki
Revision as of 15:48, 12 November 2015 by Rafahsolis (talk | contribs)
Jump to navigation Jump to search

Comand line text processing Examples:

awk -F, '{print NR, length($0)}' filename.txt  #print line number and line length
awk '{print FILENAME " " length($0)}' */PRF* | uniq

awk 'BEGIN { FS = "," } ; { print $2 }'  #Specify separator ',' can be done with -F too.
awk -F"," '$2~/^ABC$/' file  #Find in a csv second field = ABC