Dirk Moolman wrote:
Let me first start with an example:
Testfile:
This is line 1 This is line 2 This is line 3
Script:
for i in `cat testfile` do echo $i done
Output:
This is line 1 This is line 2 This is line 3
First problem - the lines are broken up and not displayed as they were anymore.
Question:
How can I get the output all on 1 line ? Let's say I want the 3 lines in the testfile to be all on 1 line, like this:
This is line 1 This is line 2 This is line 3
First off, don't use "cat" for this. Use the bash builtin read, it was made for reading from files. To get the three on separate lines without breaking on word boundaries, do while read a; do echo $a done < testfile To get everything on one single line, do while read a; do echo -n $a done < testfile You might want to put a blankspace in there while read a; do echo -n $a echo -n " " done < testfile Anders -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org