Operating System - HP-UX
1751969 Members
5099 Online
108783 Solutions
New Discussion юеВ

Re: Redirect a line from text to a file

 
SOLVED
Go to solution
Shaikh Imran
Honored Contributor

Redirect a line from text to a file

Hi all,

I want to select a particular line from the text and redirect it to a file.
The line is highlighted in the attached doc.
i.e. i want the line highlighted in the
attached doc being redirected to a file.
Note: the attached is only 4 o/p i have 200
such O/p's.
Please let me know further clarification is needed.
Thanks in advance for your help.

Thanks & Regards,
Imran Shaikh.
I'll sleep when i am dead.
4 REPLIES 4
Slawomir Gora
Honored Contributor
Solution

Re: Redirect a line from text to a file

Hi,

you can use line:

cat your_doc | awk '{ if ($1 == "LOAD") { getline; print $0 }}' >> output.txt
Fred Ruffet
Honored Contributor

Re: Redirect a line from text to a file

I don't think getting these infos from top are the best way. You can get then from "sar -u 1 1" and other sar options. Sar may provide a more parsable output.

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Franky_1
Respected Contributor

Re: Redirect a line from text to a file

Hi,

seem like a top output in a file, right ?

Simple solution would be

cat |grep "%"|grep -v TTY >> /tmp/

Looking for better solutions ... :-)

Regards

Franky
Don't worry be happy
Shaikh Imran
Honored Contributor

Re: Redirect a line from text to a file

Hi,

Thanks Swalomir Gora it worked.
Thanks Franky that also worked.
Thanks Fred but i am using this for a different purpose that's the reason i have posted this under languages & scripting.
Closing this thread

Thanks & Regards,
Imran Shaikh.


I'll sleep when i am dead.