Posted By: Anonymous
I want to insert a new line between multiple echo statements. I have tried
echo "hellon", but it is not working. It is printing
n. I want the desired output like this:
Create the snapshots Snapshot created
The simplest way to insert a new line between
echo statements is to insert an
echo without arguments, for example:
echo Create the snapshots echo echo Snapshot created
echo without any arguments will print a blank line.
Another alternative to use a single
echo statement with the
-e flag and embedded newline characters
echo -e "Create the snapshotsnnSnapshot created"
However, this is not portable, as the
-e flag doesn’t work consistently in all systems. A better way if you really want to do this is using
printf "Create the snapshotsnnSnapshot createdn"
This works more reliably in many systems, though it’s not POSIX compliant. Notice that you must manually add a
n at the end, as
printf doesn’t append a newline automatically as