News for hackers. Stuff that matters.
Re:Linux command line techniques: IO redirection and piping by stevelosh on Wednesday November 03, 2010 @01:25PM (#1865581)
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"
Re:Linux command line techniques: IO redirection and piping by ax0n on Wednesday November 03, 2010 @02:28PM (#1865857)
sudo cat ~/something.txt | grep 'hello' | sudo tee ~someoneelse/result.txt

or use "| sudo tee -a" (append) in place of >>