Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
As noted, it is a lot more work to extract a field with sed compared to awk. Here's one solution:
producing:
If you don't want the "k", omit the "dot" in the expression.
Thanks michaelrozar17, but your solution is not giving me any output in my Ubuntu 8.04 Desktop edition 32-bit x86 machine
The given sed works if the top commands output looks exactly as in post# 4. However i have tried in my machine with the top | sed .. it works!. Else try with awk.
Also remember there is a single space in between s/ and [a-z] in the sed command without which you would not get the expected output.
Last edited by michaelrozar17; 02-09-2011 at 03:49 AM..
Reason: typo..
Are you looking for an output like this.. Mem: 1025740k from the top command..?
Oh, now I got to know that why I was not getting any output for your solution and output 39; for drl. By default the "top" command outputs the result with escape sequences which is not readable and cannot be processed normally by any filter commands. So, the output has to be changed to batch mode using "-b" option before feeding into 'sed'
Below command works perfectly:
Thanks a lot for all your replies
Hi 2 all,
i have had AIX 7.2
:/# /usr/IBMAHS/bin/apachectl -v
Server version: Apache/2.4.12 (Unix)
Server built: May 25 2015 04:58:27
:/#:/# /usr/IBMAHS/bin/apachectl -M
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_worker_module (static)
... (3 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
I would like to pipe "top -n" to a text file, but I get an error:
top: cannot open /dev/kmem
kvm_open: Permission denied
I am a non-root user.
If I could find a way to get this type of output:
"Memory: 2048M real, 1516M free, 4099M swap free"
into a text file, I could further automate... (13 Replies)
Hi All,
I am running my application on a dual cpu debian linux 3.0 (2.4.19 kernel).
For my application:
<sar -U ALL>
CPU %user %nice %system %idle
...
10:58:04 0 153.10 0.00 38.76 0.00
10:58:04 1 3.88 0.00 4.26 ... (0 Replies)
Hi Everyone.-
Coul you tell me how to obtain the "Resident memory size" for any program runs on Dec TRU64 machine.
What is the command in order to obtaing this value??
Best Regards
Cristobal (1 Reply)