awk

10 views
Skip to first unread message

hq4...@gmail.com

unread,
Mar 28, 2005, 8:29:23 AM3/28/05
to bash...@googlegroups.com
awk

* Topics covered: processing columnar data
* Utilities covered: awk

* The awk utility is used for processing columns of data
* A simple example shows how to extract column 5 (the file size)
from the output of ls -l

ls -l | awk '{print $5}'

* Cut and paste this line into a Bourne shell and you should see a
column of file sizes, one per file in your current directory.
* A more complicated example shows how to sum the file sizes and
print the result at the end of the awk run

ls -al | awk '{sum = sum + $5} END {print sum}'

* In this example you should see printed just one number, which is
the sum of the file sizes in the current directory.

http://users.sdsc.edu/~steube/Bshell/

Reply all
Reply to author
Forward
0 new messages