Sego
January 17, 2012, 2:25am
1
Hi,
I've stored the output of a command into a variable.
The variable contains the following output:
[INFO ] outputline1 [INFO ] outputline2 [INFO ] outputline3 ...
How can I echo the variable so that the output is as follow and not one line:
[INFO ] outputline1
[INFO ] outputline2
[INFO ] outputline2
...
Thanks a lot!
hi... can you paste part of that code that does the printing ??
Regards,
A!
is it that you are storing the complete output in one variable ??
Sego
January 17, 2012, 2:46am
3
Hi,
Can't paste the code but what I do is:
set -x
variable=<command>
echo $variable
what I see in the output is
[INFO ] outputline1 [INFO ] outputline2 [INFO ] outputline3 ...
but what I would like in the output is
[INFO ] outputline1
[INFO ] outputline2
[INFO ] outputline2
...
When I only execute the command without redirecting to a variable the output is also:
[INFO ] outputline1
[INFO ] outputline2
[INFO ] outputline2
...
But I need the output also in a variable to work with it but keeping it on the screen as before.
Hope it makes sense.
aigles
January 17, 2012, 3:07am
4
The solution echo "$variable"
An example
$ var=$(ls -1)
$ echo $var
dir1/ dir2/ grep_with_context.txt my_test.sh tree tree.sed tree.sed
$ echo "$var"
dir1/
dir2/
grep_with_context.txt*
my_test.sh
tree*
tree.sed*
$
Jean-Pierre.