Monday, December 15, 2008

creating bash variable which has newline

Normally bash does not process \n the way c does.
myVar="Hi there.\n Me Here";
echo "$myVar";

above will just print
Hi there.\n Me Here

Use for c type of interpretation
so changing above script to
myVar="Hi there."$'\n'" Me Here";
echo "$myVar";

This will print
Hi there.
Me Here

No comments: