Unix AWK Examples

August 7, 2007 – 7:52 pm

Tip courtesy of Kyle Reynolds at http://www.camelrichard.org

extract third field separated by space
————————————–
awk ‘{ print $3 }’

extract third field separated by tab
————————————
awk -F’\t’ ‘{ print $3 }’

extract lines where third field is “111″ separated by tab
———————————————————
awk -F’\t’ ‘($3==”111″)’

extract third field where the second field is “1957″
—————————————————-
awk ‘($2==”1957″) { print $3 }’

Post a Comment