Folks,
I have an issue with disappearing newlines, when performing commands in bash scripts or at prompt.
Basically, when a command is executed and returns several lines, each line ends with a <new line> character. But, when the same command is executed and the results are placed in an environment variable, the <new line> characters are stripped.
And I obviously want to retain the <new line> characters in the variable.
By example:
[mibl@a51 mibl]$ who
mibl pts/0 Sep 15 15:19 (my.example.com)
mibl pts/1 Sep 15 08:56 (my.example.com)
mibl pts/2 Sep 15 17:13 (my.example.com)
[mibl@a51 mibl]$ X=`who`; echo $X
mibl pts/0 Sep 15 15:19 (my.example.com) mibl pts/1 Sep 15 08:56 (my.example.com) mibl pts/2 Sep 15 17:13 (my.example.com)
As can be seen, the variable $X does not contain the output from the who command with <new line> characters.
Why is this? And how can this be solved?
Running Bash 2.05a, Linux RH9.
TIA
~Mike
I have an issue with disappearing newlines, when performing commands in bash scripts or at prompt.
Basically, when a command is executed and returns several lines, each line ends with a <new line> character. But, when the same command is executed and the results are placed in an environment variable, the <new line> characters are stripped.
And I obviously want to retain the <new line> characters in the variable.
By example:
[mibl@a51 mibl]$ who
mibl pts/0 Sep 15 15:19 (my.example.com)
mibl pts/1 Sep 15 08:56 (my.example.com)
mibl pts/2 Sep 15 17:13 (my.example.com)
[mibl@a51 mibl]$ X=`who`; echo $X
mibl pts/0 Sep 15 15:19 (my.example.com) mibl pts/1 Sep 15 08:56 (my.example.com) mibl pts/2 Sep 15 17:13 (my.example.com)
As can be seen, the variable $X does not contain the output from the who command with <new line> characters.
Why is this? And how can this be solved?
Running Bash 2.05a, Linux RH9.
TIA
~Mike