Possible Duplicate:
Redirecting stdout to a file you don't have write permission on
Running a command like sudo echo 'text' >> /file.txt fails with:
bash: /file.txt: Permission denied
Running a command like
|
||||
|
|
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
|
You are telling bash to open a file and append the output of the command |
||||
|
|
|
This doesn't work because the redirection is executed by the shell, not by the command it applies to. But your shell is not running as root, only A common trick when you need have root permissions to write to a file, but not to generate the data, is to use
If you do need root permissions to generate the data, you can run two separate
When overwriting rather than appending, if you're used to your shell refusing to truncate an existing file with the |
|||
|