8 ms·
This is all pretty basic stuff. One thing that always bites me is trying to use sudo to redirect to a protected file. This doesn't work, because the shell is
by stevelosh 16y ago
This is all pretty basic stuff. One thing that always bites me is trying to use sudo to redirect to a protected file. This doesn't work, because the shell is doing the redirection, not sudo:
sudo cat ~/something.txt | grep 'hello' > ~someoneelse/result.txt
You can get around this by using sudo to run a new shell that does the redirection:
sudo sh -c "cat ~/something.txt | grep 'hello' > ~someoneelse/result.txt"
- ax0n 16y agosudo cat ~/something.txt | grep 'hello' | sudo tee ~someoneelse/result.txt or use "| sudo tee -a" (append) in place of >>