This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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