Operating System - HP-UX
1753408 Members
7329 Online
108793 Solutions
New Discussion юеВ

Re: PID Number in the TOP

 
SOLVED
Go to solution
clefeitosa
Regular Advisor

Re: PID Number in the TOP

Hi!

Thanks everbody for all answers!!!

Arturo,

I liked your tips but happens:

host:~> top -h -f top.out
host:~>awk 'NF>12&&!/^CPU/ {print $3}' top.out | head -1
/: Event not found.

Do you know why this happens (Event not found)

Please, could you explain what means the parameters "NF>12&&!/^CPU/" because I didn't understand.

Thanks a lot!
Dennis Handly
Acclaimed Contributor

Re: PID Number in the TOP

>Do you know why this happens (Event not found)

Is this in the file top.out? Or from awk?

>could you explain what means the parameters "NF>12&&!/^CPU/"

For all lines that have more than 12 fields and don't have the string "CPU" starting in column 1.
Dennis Handly
Acclaimed Contributor

Re: PID Number in the TOP

>Do you know why this happens (Event not found)

Ah! Are you using the scummy C shell?

This occurs because of the !/, even in single quotes. You can suppress it by going to a real shell or in this case by adding a space between ! and /. Or you can quote it:
% echo '\!/'
!/
clefeitosa
Regular Advisor

Re: PID Number in the TOP

Very nice!!!!

Success using the command:
awk 'NF>12&& ! / ^CPU / {print $3}' top.out | head -1 (Thanks Arturo e Dennis)

One last question... Using the above command I received the result:
PID

If I use with ... | head -2 I receive the result:
PID
13538

How can I get only 13538?? Is it possible?

Sorry for many questions....

Thanks!
Ignacio Javier
Regular Advisor

Re: PID Number in the TOP



Hi:

you could add to the sentence, "| grep -v PID"


Regards
Dennis Handly
Acclaimed Contributor

Re: PID Number in the TOP

>Using the above command I received the result:
PID

You added too many spaces. You should not have fiddled with the /^CPU/. Treat that if it was in quotes. (That is a regular expression matching expression.)
% awk 'NF>12 && ! /^CPU/ {print $3}' top.out | head -1
clefeitosa
Regular Advisor

Re: PID Number in the TOP

Dennis,

Thank you very much!!!!!
You all right...

Thanks everbody!

Best regards,
clefeitosa!