Reputation: 45
I've been trawling the web and I can't seem a way force a second command to print on a new line in a while loop, using bash. Here's an example file:
$ cat testing
foo
bar
testing
hello
Here's an example loop:
$ cat testing | while read line; do echo -e $line, $(echo $line); done
foo, foo
bar, bar
testing, testing
hello, hello
I'd like to loop to print everything on a new line, like:
foo
foo
bar
bar
testing
testing
hello
hello
I'd like this to include for if the output for the second command, the one in brackets, has more than one interation as an output, to also print this on a new line.
Thanks,
Upvotes: 0
Views: 1662
Reputation: 189327
Like this?
while read -r line; do echo "$line"; echo "$line"; done <testing
or even
sed p testing
Upvotes: 1