UNIX Programming, Certification, System Administration, Performance Tuning Reference Books
AWK Quick Columns

Most of the time when you use awk from the command line, you're doing something simple like this:

ps -ef | grep netscape | awk '{print $2}'

To save typing, use this script when you only want to use awk to print out one or more columns:

#!/bin/ksh
# awkc - print out one or more columns

p=\$$( echo $1 | sed 's/,/,\$/g' )
shift
eval "awk '{ print $p }'" $*

# eof

--------------------------------------------------------------------------------

Now you can do things like:

ps -ef | awkc 2,1
or
awkc 1,2,3 /var/adm/messages*
 

Return to : Unix System Administration Hints and Tips