Echo newline in Bash prints literal \n

Explanation

To have the newline in Bash, You can use \n to print the new statement on the new line.

Here is an example of that:

echo $'hello\n world'

So it will print the output as :

hello
world

You can also do echo "".

Here also we will take an example,

echo "Hello,"
echo ""
echo "World!"

 

Also read, How to insert an item into an array at a specific index

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *