
Redirection Operators for Testers
Published on October 1, 2025
Redirection operators (|
, >
, >>
, <
) let you chain Unix commandline commands together, and move information in and out of the chain.
|
chains i.e. sends the output of one to the input of the next.<
sends input into commands – so you can (generally)doathing < file.txt
(which is similar to the common chaincat file.txt | doathing
)>
and>>
redirect the output to a file (>
overwrites while>>
appends)2>
redirects the standard error (output) to a file
roughs below
more
>
== 1>
and directs stdout to overwrite something2>
directs stderr>>
and appends rather than overwrites. But 2>>&1
is bad syntax
The pattern 2>&1
sends errors to stdout – order is not guaranteed: streams may be interleaved, but one does not overwrite the other. 2>>&1 appends to what is there – so what if ls > dirlist 2>>&1? While
>and
>>are related,
|(pipe) and
||(OR) are not.
&(file descriptor) and
&&` (AND) are not, either.
file descriptors
The & symbol (e.g., 2>&1) refers to numbered file descriptors
for input/output streams – or for files if opened explicitly. By default:
FD 0 represents standard input (stdin),FD 1 represents standard output (stdout),FD 2 represents standard error (stderr)
Higher numbers only make sense if they’ve been opened explicitly