The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
reading text file line by line MizzGail Shell Programming and Scripting 6 04-14-2008 03:58 AM
reading line by line and grepping QueryMaster Shell Programming and Scripting 4 01-30-2008 01:12 PM
Line by line file reading... and more! ProFiction Shell Programming and Scripting 6 07-26-2007 08:32 AM
Reading line by line from a file tej.buch Shell Programming and Scripting 2 01-22-2006 10:50 PM
Reading line by line from file. akpopa UNIX for Dummies Questions & Answers 4 08-30-2001 07:20 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-22-2008
s. murat's Avatar
Registered User
 

Join Date: May 2008
Posts: 8
Stumble this Post!
reading ps command's output line by line

hi;

as a pseudo;

while read psLine
do
myFunc $psLine
done < ps

i don't want to redirect ps command's to a file. in fact, my problem is "how can i
read stdout line by line in bash, sed, awk or any?"

thanks,
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-22-2008
agn agn is offline
Registered User
 

Join Date: Feb 2008
Posts: 95
Stumble this Post!
Code:
ps | while read psLine; do myFunc $psLine; done
Reply With Quote
  #3 (permalink)  
Old 05-22-2008
s. murat's Avatar
Registered User
 

Join Date: May 2008
Posts: 8
Stumble this Post!
i find out it

ps | while read line; do
....
done

so thanks
Reply With Quote
  #4 (permalink)  
Old 05-22-2008
s. murat's Avatar
Registered User
 

Join Date: May 2008
Posts: 8
Stumble this Post!
so thanks agn
Reply With Quote
  #5 (permalink)  
Old 05-22-2008
Registered User
 

Join Date: Apr 2008
Location: Bangalore
Posts: 120
Stumble this Post!
Hi agn,

The solution u provided is fine.

can't we do like ,

while read psLine
do
myFunc $psLine
done < `ps`


I tested ur solution and this one , the second one is diplaying the value with ^J as the delimiter.

Can somebody tell the difference between the two approches..

Thanks
Penchal
Reply With Quote
  #6 (permalink)  
Old 05-22-2008
agn agn is offline
Registered User
 

Join Date: Feb 2008
Posts: 95
Stumble this Post!
Quote:
...the second one is diplaying the value with ^J as the delimiter.
Can you paste the output ?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0