I am currently writing some code for a shell script that needs a blank line between two parts of the script, as thus they can be separated when output is displayed to the user.
My question is, I am not sure what the preferred practice is in a shell script for a blank line.
Is it preferred practice to just write echo
and nothing else or to write echo " "
as in echo with quotes and blank between the quotes?
There are a couple of different ways we can print a newline character. The most common way is to use the echo command. However, the printf command also works fine. Using the backslash character for newline “\n” is the conventional way.
Blank lines are also considered to be lines, so don't start your script with an empty line. As noted before, this implies that the Bash executable can be found in /bin.
echo is used to produce a new line in Linux. echo -e '\n\n' 3 lines and so on. e.g.
echo
is preferred. echo " "
outputs an unnecessary space character. echo ""
would be better, but it's unnecessary.
but you can use
echo -e "Hi \n"
and print a blank line after Hi, with -e interprets the \n character.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With