stdin, stdout, stderr
Stream
0
stdin1
stdout2
stderr> /dev/tty
- print to screen which cannot be passed directly
Redirect
|
pipecommand1 | command2
: stdout pipe tocommand2
>
pass content to filecommand > file
: stdout tofile
(1>
)command 2> file
: stderr2
tofile
command &> file
: stderr2
+ stdout1
tofile
(2>&1
)command &> /dev/null
: suppress all
<
pass content from filereadarrary -t array < file
<<
heredocvar=$( cat << EOF
- set varcat << EOF > file
- pass content to file
<<<
herestring - pass content to commandcommand2 <<< $( command1 )
: multiline stdout tocommand2
command <<< "$var"
: read variable as multiline stdin (here string)
script -c
- capture everything on screen to file. (for commands not stdout to var)script -c 'command' file
- capture/dev/tty
to file
accummulate stdout
{
command1
command2
command3
} > file