How to insert a line break inside echo in shell script?

9

I wanted to know if there is any way to insert a line break within the echo of the shell script.

For example, in the command:

echo "Bom dia fulano"

I would like the output to be:

Bom dia
fulano

I know you can do it like this:

echo "bom dia"
echo "fulano"

But I would really like to know if there is any way to do this with a echo only.

    
asked by anonymous 09.07.2015 / 13:25

3 answers

12

Try

echo -e "Bom dia\nfulano"

e causes the newline character to be interpreted.     

09.07.2015 / 13:51
0

You can use printf that works well:

printf "Ola\nMundo\n"
    
26.08.2017 / 14:33
-3

This format also works:

echo "
Bom dia

Fulano!"
    
26.08.2017 / 14:19