for statement in bourne shell script
Hello,
I am parsing a file with entries like "word1 word2 word3". I need to parse each line, so I used a "for" statement in a Bourne shell script. Something like this: Code:
for line in `cat $file` Any idea to resolve this? Thanks. |
Hi,
Is this what you want: Code:
for line in "`cat $file`" Hope this helps. |
Quote:
Code:
cat $file | while read line Code:
while read line |
More generally, there are three main solutions when you want to read the output of something line by line:
Code:
something | while read line; do process "$line"; done Code:
SaveIFS="$IFS" Code:
while read line; do process "$line"; done < <(something) |
All times are GMT -5. The time now is 07:21 AM. |