2

I am storing the multiple lines in a variable and when I am trying to access them it is showing in a single line.

$ echo -e "A\nB"
A
B
$ VAR=`echo -e "A\nB"`
$ echo $VAR
A B

let me know is there any way to get the output as same as command. I want A, B to be in different lines while accessing it.

Sriharsha Kalluru
  • 1,743
  • 3
  • 21
  • 27

2 Answers2

4

Need quotes when echoing:

$ var=$(echo -e "A\nB")

$ echo "$var"
A
B
Chris Seymour
  • 83,387
  • 30
  • 160
  • 202
0

$ VAR=echo -e "A\nB" $ echo "$VAR" A B

Ganga
  • 1