Linux command line techniques: IO redirection and piping
blog.interstellr.com
blog.interstellr.com
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"or use "| sudo tee -a" (append) in place of >>
This probably comes from learning Unix via graphical interfaces, such as GNOME on Ubuntu, OS X, etc., and blog posts by other people with the same background.
Kernighan and Pike's _The Unix Programming Environment_ is probably still the best place to learn this stuff.
Normally it goes something like this:
A: I have problem X with Y.
B: Oh I don't know anything at all about Y, but if you migrate to Z I bet you won't have the problem any more.
A: Okay I'll do that. Thanks!
or:
A: I have a problem X with Y.
B: Oh did you try (completely unrelated irrelevant thing)
A: No, but I will. Thanks!
Seriously.
Unfortunately, Linux newbies searching for help may run across bad advice from people with barely more experience, creating a feedback loop.
But seriously, it's helpful as I dive more into the command line.
The alternative is to do what reddit does: subreddits. Or do what reddit doesn't do: automatic filtering (essentially per-user subreddits based on past voting).
jmhobbs@katya:~$ cat file-that-doesnt-exist
cat: file-that-doesnt-exist: No such file or directory
jmhobbs@katya:~$ cat file-that-doesnt-exist 2>&-
jmhobbs@katya:~$the above is wrong. that will clobber the file.