System notes



awk.notes

Version date: Thu May 24 14:28:12 EDT 2012

Awk notes from the supplementary documents, vol II Programmers
Ultrix 32 guide. aa-bg67a-te
Page 3-5 (m) corcoran 26Jul1990

Usage:
awk [files]

Program Structure:
pattern {action}

Fields:
$1, $2, etc.
$0 is whole input record

Actions:
{print}
{print NR, NF $0}
{print $1 >"foo"}
{ print length($0)}
{$1 = $2 + $3; print $0}

# this is a comment

Regular Expressions:
/string/ matches any biggerstring containing string
/[Mm]ike|[Dd]ale|[Ss]heila/

Loops:
i=1
while(i<=NF)
{
print $i
++i
}

for (i=1;i<=NF;i++)
print $i



Please read The Standard Disclaimer regarding information found in these pages.

To return to the top of the Corcoran document archives Click Here

If you came here directly from a search engine, and would like to view these pages in the proper frames from the top, Start Here

Or start at the very top of Mike Corcoran's home page