2010-04-08 5 views
4

BASH 셸 리디렉션의 많은 용도를 보여주는 좋은 치트 시트가 있습니까? 나는 내 학생들에게 그런 것을주고 싶다. 내가 좋아하는 것 몇 가지 예 덮여 볼 수 있습니다 :bash 셸 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 

(또는 우리가이 사회의 위키를 만들고 여기에 그런 것들을 열거 할 수있다)

감사합니다!

setjmp는

+1

무슨 잘못? 그냥 인쇄 해! hehe. –

+0

치트 시트는 아니지만 여기에는 훌륭한 토론이 있습니다 (http://mywiki.wooledge.org/BashGuide/InputAndOutput). –

답변

0

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

당신의 학생을 볼 수 있습니다. 이는 IO 리디렉션과 매우 밀접하게 관련됩니다.

편집 : 이미 데니스 윌리엄슨의 링크처럼 보이는 프로세스 substition :)에 대해 이야기

관련 문제