What you need to know about AWK

General structure

BEGIN { print "BEGIN" }

      /filter1/     { print $0 }      
      /$6 == "Nov"/ { print $1, $2 } 
END   { print "END" }

Special keywords

  • NF means “Number of Fields/Columns in this row”
  • $0 is the whole row
  • $1 is column 1
  • $2 is column 2
  • etc
  • $NF is the last column
  • $(NF-1) is the penultimate column
  • NR is the Number of Rows (the current row number)

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.