Echo newline in Bash prints literal \n

This could better be done as

x=”\n”
echo -ne $x

-e option will interpret backslahes for the escape sequence
-n option will remove the trailing newline in the output

PS: the command echo has an effect of always including a trailing newline in the output so -n is required to turn that thing off (and make it less confusing)

This could better be done as x=”\n” echo -ne $x -e option will interpret backslahes for the escape sequence -n option will remove the trailing newline in the output PS: the command echo has an effect of always including a trailing newline in the output so -n is required to turn that thing off (and make it less confusing)

Source: Echo newline in Bash prints literal \n – Stack Overflow

Echo newline in Bash prints literal \n was last modified: February 2nd, 2019 by Jovan Stosic

Leave a Reply