>:
这是个重定向命令,也就是将结果写入一个新的文件,如果该文件已存在,里面的内容将会被覆盖。 for example:ls -i *|awk '{print $1}'|sort -nu >in.txt
>> the >> redirection operator can be used to append to existing files.for example.you could use the following command to append a one-line footnode to in.txt: echo"end of list">>in.txt
use >> command and the > command's consequence will writed in file,don't display on the terminate.the >and the >> all standard output.
sandard input can also be redirected.the input redirection operator is <,for example.the following command will send a mail message with the contents of the file in.txt to user jedan:
mail -s "idone list" jdean<in.txt
send stdout to file. $cmd >file or cmd 1>file
send stderr to file. $cmd 2>file
send both stdout and stderr to file $cmd >file 2>&1
send stdout to file1 and stderr to file2 $cmd >file 2<file2
receive stdin from file $cmd <file
append stdout to file $cmd >>file or $cmd 1 >>file
append stderr to file $cmd 2 >>file
append both stdout and stderr to file $cmd >>file 2>&1
pipe stdout from cmd1 to cmd2 $cmd1|cmd2
pipe stdout and stdin from cmd1 to cmd2 $cmd1 2>&1|cmd2
tee
tee [options] files
read from standard input and write both to one or more files and to standard output(analogous(类似的,相似的)to a tee junction(交叉点,汇合处)in a pipe) -a append to files rather than overwriting them
example:suppose you're running a pipeline of commands cmd1,cmd2 and cmd3 $cmd1|cmd2|cmd3>file1 this sequence puts the ultimate output of the pipeline into file1.however,you may also be interested in the intemediate result of cmd1.to create a new file_cmd1 containing those result.use tee: $cmd1|tee file_cmd1|cmd2|cmd3>file1