PDA

View Full Version : Looping out lines.


Zyko
June 7th, 2005, 10:07 AM
Hi!

I have searched all day for a way to find out how to loop out each line in a document.

for example:

lines.txt:
Line 1
Line 2
Line 3

and i want a string to be set for each row in the document



So this would set

(Loop nr1)
line=Line 1
(Loop nr2)
line=Line 2


and so on...

Does anyone know?

LordHunter317
June 7th, 2005, 10:25 AM
Kind of hard to even suggest a solution when you don't specify what language.

Zyko
June 7th, 2005, 12:30 PM
oh, i'm sorry.. its sh .. /bin/sh

LordHunter317
June 7th, 2005, 12:53 PM
cat /example.txt | while read line ; do
# commands go here, line is in $line
done

Zyko
June 7th, 2005, 01:21 PM
Ty so much, you just made my day :)