Possible Duplicate:
Redirecting stdout to a file you don't have write permission on
I am trying to append a line of text to a write protected file.
I tried to accomplish this with sudo echo "New line to write" >> file.txt
but I get a permission denied error — presumably because it is trying to sudo the string, not the act of appending it to a file.
If I run sudo vi file.txt
and authenticate I can happily write away.
Any help would be greatly appreciated.
sudo echo "New line ..
in your post? – Levon Jul 11 '12 at 11:28