Skip to content

Instantly share code, notes, and snippets.

@NateWeiler
Created January 6, 2021 02:46
Show Gist options
  • Save NateWeiler/4cc16a308facf41ffc03a65abf92fd80 to your computer and use it in GitHub Desktop.
Save NateWeiler/4cc16a308facf41ffc03a65abf92fd80 to your computer and use it in GitHub Desktop.
Adding a new line in a shell script examples
#!/bin/sh
echo -e "new line in shell script\n"
echo -e "new line using echo\n"
echo -e "Similar result, using cat\n"
echo -e "hello\nworld\n"
echo -e "new line using cat\n"
cat <<EOF
echo -e "\nnew line using printf\n"
printf "hello\nworld"
echo -e "\nprintf has more consistent behavior than echo. The behavior of echo varies greatly between different versions."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment