![]() |
|
|
grep unix.com with google
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Our Members | 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. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
Preserve first line and search in others
Hi gurus Is possible to preserve first line of text and search in another lines ? the only way that I think is: Code:
ps aux | awk '{if (NR==1) {print $0} else if ($11 ~ /sshd/) {print $0}}'
but is there any more elegant way ? thanks |
|
|||
|
Quote:
Code:
lakris@landet:~$ ps aux|head -1;ps aux|grep firefox|grep -v grep USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND lakris 2035 13.9 12.2 344128 125440 ? Sl 16:42 0:47 /usr/lib/firefox-3.5.5/firefox -new-tab http://art.gnome.org/backgrounds/ lakris@landet:~$ Best regards, Lakris |
|
|||
|
Code:
ps aux | egrep "^U|ssh[d]" Code:
ps aux | sed '1p;/ssh[d]/!d' ---------- Post updated at 08:13 AM ---------- Previous update was at 08:04 AM ---------- Not the same format but.. Code:
ps -fC "sshd" Last edited by Scrutinizer; 11-14-2009 at 12:21 PM.. |
|
|||
|
thanks ![]() Code:
ps aux | awk 'NR==1||$11~/sshd/' is nice
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Search a line and output next line as well | kamranjalal | Shell Programming and Scripting | 10 | 12-29-2008 10:59 PM |
| Perl script to search a line and copy it to another line | ammu | Shell Programming and Scripting | 3 | 12-29-2008 05:12 PM |
| search for a string ,replace the whole line with new line | kkraja | Shell Programming and Scripting | 4 | 08-07-2008 03:26 AM |
| query on how to search for a line and read 4th word from that line | jaggesh | UNIX for Dummies Questions & Answers | 4 | 07-01-2008 11:21 PM |
| Perl: Search for string on line then search and replace text | Crypto | Shell Programming and Scripting | 4 | 01-04-2008 10:24 AM |