4

BASH シェル リダイレクトのさまざまな用途を示す優れたチート シートはありますか? そんなものを生徒たちに与えたいと思っています。取り上げてほしいいくつかの例:

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

4

4 に答える 4

2

http://wiki.linuxquestions.org/wiki/Bash-operators

于 2010-04-08T23:45:57.437 に答える
2

Peteris Krumins もかなり包括的なチート シートを持っています: http://www.catonmat.net/blog/bash-redirections-cheat-sheet/

于 2012-09-18T17:51:22.490 に答える
1

you can also look at Advanced Bash Guide

于 2010-04-08T23:47:25.520 に答える
0

http://tldp.org/LDP/abs/html/process-sub.html

学生は、プロセスの置き換えも少し気に入るかもしれません。これは、IO リダイレクトと非常に密接に関連しています。

編集:デニス・ウィリアムソンのリンクはすでにプロセス置換について話しているようです:)

于 2010-04-09T21:44:14.633 に答える