Skip to content

Instantly share code, notes, and snippets.

@ff4500 ff4500/myscript_v03_echo.sh Secret
Created Jan 23, 2020

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.