var1="Hello"
var2="World!"
logwrite="$var1\n$var2"
echo -e "$logwrite" >> /Users/username/Desktop/user.txt
Explanation:The
\n
escape sequence indicates a line feed. Passing the -e
argument to echo enables interpretation of escape sequences.It may even be simplified further:
var1="Hello"
var2="World!"
echo -e "$var1\n$var2" >> /Users/username/Desktop/user.txt
or even:echo -e "Hello\nWorld! " >> /Users/username/Desktop/user.txt
No comments:
Post a Comment