Cheat sheet showing shell redirection behavior <stdout / stderr bash
Is there a good cheat sheet demonstrating the many uses of BASH shell redirection? I would like to convey such things to my students. Some examples that I would like to consider:
cmd > output_file.txt #redirect stdout to output_file.txt cmd 2> output_file.txt #redirect stderr to output_file.txt cmd >& outpout_file.txt #redirect both stderr and stdout to output_file.txt cmd1 | cmd2 #pipe cmd1 stdout to cmd2 stdin cmd1 2>&1 | cmd2 #pipe cmd1 stdout and stderr to cmd2 stdin cmd1 | tee result.txt #print cmd1 stdout to screen and also write to result.txt cmd1 2>&1 | tee result.txt #print stdout,stderr to screen while writing to result.txt (or we could just do this community wiki and list such things here)
Thanks!
Setjmp
+4
4 answers
Peteris Krumins also has a rather extensive deceiver: http://www.catonmat.net/blog/bash-redirections-cheat-sheet/
+2
http://tldp.org/LDP/abs/html/process-sub.html
Your students may appreciate a little substitution process. It is very closely related to IO redirection.
Edit: it looks like Dennis Williamson's link is already talking about an approach to the process :)
0