35

The new line \n is not taken account in the shell strings:

str="aaa\nbbbb"
echo $str

Output:

aaa\nbbbb

Expected result:

aaa
bbbb

How can I add a new line in the string?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
developer
  • 4,744
  • 7
  • 40
  • 55
  • linuxcdeveloper: always try to use echo -e "your display part" it makes the right effect( -e : enable interpretation of backslash escapes ) – Ranjithkumar T Dec 17 '13 at 06:33

1 Answers1

77
$ echo "a\nb"
a\nb
$ echo -e "a\nb"
a
b
Adam Siemion
  • 15,569
  • 7
  • 58
  • 92