Logo Questions Linux Laravel Mysql Ubuntu Git Menu

How to display newline in ssh

I'm trying to do the following:

ssh user@server "echo \"Test \n for newline\""

This displays:

test \n for newline

How do I get the shell to interpret \n as an actual newline?

like image 463
hax0r_n_code Avatar asked Mar 23 '23 13:03


1 Answers

Try using the -e option, e.g., echo -e "Test \n for newline".

If your echo doesn't have a -e option, then I'd use printf. It's widely available and it does not have nearly as many variations in it's implementations.

like image 178
cmt Avatar answered Mar 26 '23 02:03