Bash Redirections

Categories:
SyntaxDescription
< filestdin from file
> filestdout to file1
>| filestdout to file2
>> fileappend stdout to file
2> filestderr to file
2>&1stderr to stdout
&> fileboth stdout and stderr to file
> file 2>&1both stdout and stderr to file
&>> fileappend both stdout and stderr to file
>> file 2>&1append both stdout and stderr to file
<<END“here-document”: stdin from lines until END
<<-END“here-document” with leading tabs stripped
<<'END'“here-document” without expansions and substitutions
<<< string“here-string”: stdin from string

  1. Fails if option noclobber is set (set -o noclobber) and file exists. ↩︎

  2. Overwrites file if it exists. ↩︎

See Also