awkIntro

awkIntro - Introduction to Awk Awk is a convenient and...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
    Introduction to Awk Awk is a convenient and expressive  programming language that can be  applied to a wide variety of computing  and data manipulation tasks.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
    Awk Works well on record-type data Reads input file(s) a line at a time Parses each line into fields Performs user-defined tests against  each line, performs actions on matches
Background image of page 2
    Other Common Uses Input validation Every record have same # of fields? Do values make sense (negative time,  hourly wage > $100, etc.)? Filtering out certain fields Searches Who got a zero on lab 3? Who got the highest grade? Many others (it's late)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
    Invocation Can write little one-liners on the command  line ( very  handy): print the 3 rd  field of every line: $ awk '{ print $3 }' input.txt Execute an awk script file: $ awk –f script.awk input.txt Or, use this sha-bang as the first line, and  give your script execute permissions: #!/bin/awk -f
Background image of page 4
    Form of an AWK program AWK programs are entries of the form: pattern  {  action  }  pattern  – some test, looking for a pattern  (regular expressions) or C-like conditions if null, actions are applies to 
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 16

awkIntro - Introduction to Awk Awk is a convenient and...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online