是否有一个很好的备忘单来演示BASH shell重定向的多种用法?我很想把这样的事情给我的学生。看到覆盖一些例子,我想:显示bash shell stdout/stderr重定向行为的备忘单
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's stdin
cmd1 2>&1 | cmd2 #pipe cmd1 stdout and stderr to cmd2's stdin
cmd1 | tee result.txt #print cmd1's 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
(或者我们可能只是使这个社区wiki和一一赘述这样的事情)
谢谢!
的setjmp
什么错在你那里吗?只是打印出来!呵呵。 – 2010-04-08 23:44:42
虽然不是备忘单,但[这里有一个很好的讨论](http://mywiki.wooledge.org/BashGuide/InputAndOutput)。 – 2010-04-09 17:52:35