(Bash) Let `echo` print newline using `\n`
By default echo
simply prints \n
literally as is, instead of printing a newline.
To force it to print newline, use -e
flag to parse as regex, e.g.:
echo "Hello\nWorld!" # Prints "Hello\nWorld!" in a single line
echo -e "Hello\nWorld!" # Prints "Hello", breaks line, then "World!"
Or, simply use printf
instead.
References:
Written on October 19, 2021