Tuesday, October 14, 2008

c shell redirection.

http://www.mathinfo.u-picardie.fr/asch/f/MeCS/courseware/users/help/general/unix/redirection.html

http://hi.baidu.com/sanshan/blog/item/98e4c3ce3313690593457e69.html


http://www.linuxdevcenter.com/pub/a/linux/lpt/13_01.html (this is the best link I have seen)


Table 1: Common Standard I/O Redirections

Functioncshsh
Send stdout to fileprog > fileprog > file
Send stderr to file
prog 2> file
Send stdout and stderr to fileprog >& fileprog > file 2>&1
Take stdin from fileprog < fileprog < file
Send stdout to end of fileprog >> fileprog >> file
Send stderr to end of file
prog 2>> file
Send stdout and stderr to end of fileprog >>& fileprog >> file 2>&1
Read stdin from keyboard until c prog <<cprog <<c
Pipe stdout to prog2prog | prog2prog | prog2
Pipe stdout and stderr to prog2prog |& prog2prog 2>&1 | prog2


  • The C shell doesn't give you an easy way to redirect standard output without redirecting standard error. A simple trick will help you do this. To put standard output and standard error in different files, give a command like:

    % ( prog > output ) >& errors
  • No comments: