Skip to content

Instantly share code, notes, and snippets.

@ff4500
Created January 23, 2020 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ff4500/d040ac928c856dfe58d8d64360a4c435 to your computer and use it in GitHub Desktop.
Save ff4500/d040ac928c856dfe58d8d64360a4c435 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
filepath="$HOME/Desktop/"
filename="mysecondnewfile.txt"
echo "I'm an echo. Enjoy your new file - now with content!"
echo "This is my test file." > "${filepath}${filename}"
# To give your output a little more space, you can simply use
# an echo to print an empty line to the console
# ----------------------------------------------------------------------
echo
echo
echo
# Example 1
# regular echo command - "\n" typically defines a new line in a script
# ----------------------------------------------------------------------
echo
echo "------------------------------------------------------"
echo "I'm a line of text, you\nknow... for testing.\n"
echo "I'm a second line of text."
echo "------------------------------------------------------"
echo
# Example 2
# echo -n: Trailing newline is omitted
# ----------------------------------------------------------------------
echo
echo "------------------------------------------------------"
echo -n "I'm a line of text,\nyou know... for testing.\n"
echo -n "I'm a second line of text."
echo "------------------------------------------------------"
echo
# Example 3
# echo -E: Disable interpretation of backslash escaped characters
# ----------------------------------------------------------------------
echo
echo "------------------------------------------------------"
echo -E "I'm a line of text,\nyou know... for testing.\n"
echo -E "I'm a second line of text."
echo "------------------------------------------------------"
echo
# Example 4
# echo -e: Enable interpretation of backslash escaped characters
# ----------------------------------------------------------------------
echo
echo "------------------------------------------------------"
echo -e "I'm a line of text,\nyou know... for testing.\n"
echo -e "I'm a second line of text."
echo "------------------------------------------------------"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment