![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| column number, awk, help | jkl_jkl | Shell Programming and Scripting | 2 | 03-15-2008 10:16 PM |
| Sorting in unix using column number | swat | UNIX for Advanced & Expert Users | 1 | 11-15-2007 06:59 AM |
| returning a column number | scriptingmani | Shell Programming and Scripting | 2 | 07-06-2007 10:36 PM |
| awk to select a column from particular line number | mab_arif16 | Shell Programming and Scripting | 4 | 05-08-2006 06:26 AM |
| identifying duplicates line & reporting their line number | stresslog | UNIX for Dummies Questions & Answers | 5 | 04-24-2006 01:43 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Identifying the column number
I'd like to be able to identify in which column a string occurs. So far I know that I can tell how many columns there are and how to return a specific column: Code:
$ sar -r | grep 'kbswpcad' | awk 'NF = 9 { print $NF }'
%swpused
I've even managed to get the columns to output to an array but I think this is over complicated: Code:
$ sar -r | head -3 | tail -1 | tr -s [:blank:] " " | awk '{ split($0, head, " ") } END { for (i in head) print i, " : "head[i] }'
4 : %memused
5 : kbbuffers
6 : kbcached
7 : kbswpfree
8 : kbswpused
9 : %swpused
10 : kbswpcad
1 : 00:00:01
2 : kbmemfree
3 : kbmemused
Using the above I still can't do a string check on the array element. So, in short, how find out which column %swpused is in? Thanks in advance
|
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|