Pipes and redirections in tcsh
A quick reference to pipes and redirections in tcsh.
Pipes
Use the standard output of
program_1as the standard input ofprogram_2:program_1 | program_2Use the standard and diagnostic outputs of
program_1as the standard input ofprogram_2:program_1 |& program_2
Redirections
Open file name as the standard input:
program < nameUse file name as the standard output:
program > nameAppend the output to the end of file name:
program >> nameRoute both the standard and diagnostic outputs to file name:
program >& nameAppend both the standard and diagnostic outputs to file name:
program >>& name
Tips
To route the standard and diagnostic outputs to separate files, use the following syntax:
( program > outfile ) >& errfileTo route the diagnostic output to a file and the standard output to the terminal, use:
( program > /dev/tty ) >& errfileTo retain only the diagnostic output, redirect the standard output to
/dev/null:program > /dev/null ( program > /dev/null ) >& errfileIn order to test pipes and redirections, use the following Perl program:
#!/usr/bin/perl print STDOUT "STDOUT: Standard output\n"; print STDERR "STDERR: Diagnostic output\n";