Created
September 11, 2022 20:11
-
-
Save coltenkrauter/eb0dbb4804857ebd8eeecce8f7177cc2 to your computer and use it in GitHub Desktop.
Bash/sh/zsh one liners, append to a file with sudo
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
# 1. One liner, append to a file | |
echo "A new line at the end of the file" >> file.txt | |
# 2. One liner, append to a file including newlines | |
echo -e "\n\nA new line at the end of the file that is preceeded by some new lines" >> file.txt | |
# 3. One liner, append to a file the requires sudo | |
echo "A new line at the end of the file that requires sudo" | sudo tee -a /etc/fstab | |
--- | |
Related | |
# 4. Overwrite a file | |
echo "A new line at the end of the file" > file.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment