Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Standard input into a while loop

Status
Not open for further replies.

meetramana

Programmer
Feb 2, 2005
57
US
Hi all,

How do I execute a while loop at the command prompt which takes stdin as the input.

I just did that 3 days ago. and completely forgot how I did that.

Breaking my head for 3 hours recalling how I did that still couldn't recall

Can you please suggest me on how to do it

Thanks
 
Something like this?
Code:
#!/bin/ksh

somecommand | while read LINE
do
    # Process each line

    print ${LINE}
done
Hope this helps.
 
Thankyou,

I was so mixed up with things and really didn't pay attention to a silly thing

Don't know what made me put
while read $LINE instead of
while read LINE

I noticed that when I was comparing what I wrote with what you suggested and for the first five minutes I really couldn't see the difference but finally noticed it.

Thankyou once again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top