pipe
operatortee
command<
", "0<
": STDIN operator (file, keyboard, mouse, ...)>
", "1>
": STDOUT operator (file, monitor, printer, ...)2>
": STDERR operator (file, monitor, printer, ...)&>
": STDOUT & STDERR operator (file, monitor, printer, ...)<
" STDIN redirection operator.$ grep foo < file1
0<
" STDIN redirection operator (same as "<
").$ grep foo 0< file1
<
" or "0<
" is optional,
as it's the default operator in the absence of an explicit redirection operator.$ grep foo file1
<<
" that allow you to type a text that can be use a standard input for a command.command <<FLAG <ENTER> text <ENTER> ... FLAG<ENTER>
$ sort <<end > aaa > ccc > bbb > end aaa bbb ccc
>
" STDOUT redirection operatorls -al
" in the file "file1":
$ ls -al > file1
1>
" STDOUT redirection operator (same as ">
")ls -al
" in the file "file1":$ ls -al 1> file1
>>
" STDOUT redirection operator + appendls -al
" in the file "file1":$ ls -al >> file1
1>>
" STDOUT redirection operator + append (same as >>
)ls -al
" in the file "file1":$ ls -al 1>> file1
2>
" STDERR redirection operatorls: -: No such file or directory
) of the comand "ls -
" in the file "file1":$ ls - 2> file1
2>>
" STDERR redirection operator + appendls: -: No such file or directory
) of the comand "ls -
" in the file "file1":$ ls - 2>> file1
1>&2
" redirect STDOUT to the same "stream" as STDERRls -al
" to the same "stream" as STDERR ("file1"):$ ls -al 2> file1 1>&2 $ ls -al 2>> file1 1>&2
2>&1
" redirect STDERR to the same "stream" as STDOUTls: -: No such file or directory
) of the command "ls -
" to the same "stream" as STDOUT ("file1"):
$ ls - > file1 2>&1 $ ls - >> file1 2>&1 $ ls - 1> file1 2>&1 $ ls - 1>> file1 2>&1
/dev/null
:
$ ls - > file1 2>/dev/null
&>
" both STDOUT and STDERR redirection operator.ls -al
" in the file "file1":$ ls -al &> file1
ls: -: No such file or directory
) of the comand "ls -
" in the file "file1":
$ ls - &> file1
pipe
operator
pipe
operator redirects the output of a command (on the left of the pipe) as input to the next command (on the right of the pipe).# "|" pipe operator $ ps -ef | grep java
tee
command
tee
command redirects the output of a script to files and STDOUT.$ ls -1 | tee files file1 file2 file3 $ tee file1_copy < file1 file1 content