|
|
|
|
UGU: Unix Guru Universe - Unix Tip #4573- September 17, 2024
- Home : Help
: Today's Tip
Unix Tip #4573- September 17, 2024
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
4572
- MONITORING ROOT IN THE PASSWORD FILE
4571
- CREATE YOUR OWN GROUP ALIASES
4570
- KILL X
4569
- ALTERNATIVE TO CP
4568
- -------- 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 |
|
|
|
|