[Bash] New line character in variable
Hi,
How can I include a new line character in a variable in a bash shell script? test.sh ============= myvar="line1\nline2" echo $myvar # gives line1\nline2 Doesn't work...and I have already tried many different combinations (\r\n, etc etc). Thanks in advance. Michael |
Hi,
Use echo -e instead of echo. Code:
#!/bin/bash Hope this helps. |
druuna is right.
See also: Code:
man echo |
Quote:
|
No need for the echo command, myvar=$'\n' will also do the trick.
|
All times are GMT -5. The time now is 01:12 AM. |