|
AWK : AWK is a programming language used to manipulate data and create
reports.
A= Alfred Aho W=Peter Weinberg K=
Brian Kernighan
The authors of the language.
Versions of AWK. There are is a number of version of awk: old awk, new awk,
gnu awk (gawk), POSIX awk and others.
On most systems, the command is awk using the old version, nawk if using
the new version, and gawk if using the gnu version.
Format :
awk 'pattern' filename
awk '{action}' filename
awk 'pattern {action}' filename
------------------------------------------------------------
Sample file named employees
Tom Jones 4425
5/12/67 543355
Mary Adams 5336
12/4/63 28764
Sally Chuning 1996
7/14/56 67000
Billy Brom 1683
9/21/55 336589
------------------------------------------------------------
Exercise : try the following awk commands.
awk '/Mary' employees
awk '{print $1}' employees
Tom Mary Sally Billy
awk '/Sally/{print $1, $2}' employees
Sally Chuning
date | awk '{print "Month: " $2 " \nYear: " , $6}'
Month: Jul
Year : 2002
|