Skip to content

Instantly share code, notes, and snippets.

@ksdev-pl
Last active August 29, 2015 14:14
Show Gist options
  • Save ksdev-pl/62cf4119eab5a9eaf92c to your computer and use it in GitHub Desktop.
Save ksdev-pl/62cf4119eab5a9eaf92c to your computer and use it in GitHub Desktop.
Write / append some text to a file #serwer

If you want to write some text to a file that needs a root privileges, you do it this way:

echo "Text I want to write" | sudo tee /path/to/file > /dev/null

or:

sudo sh -c 'echo "Text I want to write" > /path/to/file'

If you just want to append some text, you do it this way:

echo "Text I want to write" | sudo tee -a /path/to/file > /dev/null

or:

sudo sh -c 'echo "Text I want to write" >> /path/to/file'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment