|
|
|
|
UGU: Unix Guru Universe - Unix Tip #4145- June 17, 2012
- Home : Help
: Today's Tip
Unix Tip #4145- June 17, 2012
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:
------------------- CUT HERE ---------------------------
#!/bin/ksh
# awkc - print out one or more columns
p=\$$( echo $1 | sed 's/,/,\$/g' )
shift
eval "awk '{ print $p }'" $*
# eof
------------------- CUT HERE ---------------------------
Now you can do things like:
ps -ef | awkc 2,1
or
awkc 1,2,3 /var/adm/messages*
This tip generously supported by: kbeer@dbna.com
NOTE: All tips provided are USE AT YOUR OWN RISK. Tips are submitted
by various unix admins around the globe. UGU suggest you read and
test each tip in a non-volitile environment before placing into
production.
LAST 5 TIPS
4144
- MONITORING ROOT IN THE PASSWORD FILE
4143
- CREATE YOUR OWN GROUP ALIASES
4142
- KILL X
4141
- ALTERNATIVE TO CP
4140
- -------- REMOVE THE DASHES
I want to
SUBSCRIBE
and get a UGU Tip everyday.
I want to
UNSUBSCRIBE
and NOT get a UGU Tip everyday.
If you have a UNIX TIP let us know, we just may use it:
(All tips become the property of the Unix Guru Universe)
|
|
|
Copyright 1994-2024 Unix Guru Universe |
|
|
|
|