标准输出重定向
">" 操作符:覆盖目标文件内容
linux@linux:~/linux/linux/cmdline$ date > foo
linux@linux:~/linux/linux/cmdline$ cat foo
Fri May 8 09:55:42 CST 2015
">>" 操作符:在目标文件尾部追加输出内容
linux@linux:~/linux/linux/cmdline$ date >> foo
linux@linux:~/linux/linux/cmdline$ cat foo
Fri May 8 09:55:42 CST 2015
Fri May 8 09:57:02 CST 2015
标准错误重定向
"2>" 操作符:覆盖目标文件内容
linux@linux:~/linux/linux/cmdline$ ls inexistent_dir 2> ls-error.txt
linux@linux:~/linux/linux/cmdline$ cat ls-error.txt
ls: cannot access inexistent_dir: No such file or directory
"2>>" 操作符:在目标文件尾部追加输出内容
linux@linux:~/linux/linux/cmdline$ ls inexistent_dir 2>> ls-error.txt
linux@linux:~/linux/linux/cmdline$ cat ls-error.txt
ls: cannot access inexistent_dir: No such file or directory
ls: cannot access inexistent_dir: No such file or directory
将标准输出与标准错误重定向到同一文件
"&>" 操作符:覆盖目标文件内容
linux@linux:~/linux/linux/cmdline$ date &> foo
linux@linux:~/linux/linux/cmdline$ cat foo
Fri May 8 10:16:12 CST 2015
linux@linux:~/linux/linux/cmdline$ ls inexistent_dir &> foo
linux@linux:~/linux/linux/cmdline$ cat foo
ls: cannot access inexistent_dir: No such file or directory
"&>>" 操作符:在目标文件尾部追加输出内容
linux@linux:~/linux/linux/cmdline$ echo 'hello world' > foo
linux@linux:~/linux/linux/cmdline$ date &>> foo
linux@linux:~/linux/linux/cmdline$ ls inexistent_dir &>> foo
linux@linux:~/linux/linux/cmdline$ cat foo
hello world
Fri May 8 10:25:24 CST 2015
ls: cannot access inexistent_dir: No such file or directory
标准输入重定向
"<" 操作符
linux@linux:~/linux/linux/cmdline$ echo 'hello world' > foo
linux@linux:~/linux/linux/cmdline$ cat < foo
hello world
管道
"|" 操作符
linux@linux:~/linux/linux/cmdline$ ls /usr/bin | grep '^zip'
zip
zipcloak
zipgrep
zipinfo
zipnote
zipsplit
详细介绍Linux重定向的使用:http://www.linuxdiyf.com/linux/546.html
cat命令利用Linux重定向合并文件:http://www.linuxdiyf.com/linux/8182.html
Linux重定向console口控制台:http://www.linuxdiyf.com/linux/7692.html
Linux管道pipe使用实例:http://www.linuxdiyf.com/linux/10952.html
Linux中管道以及重定向:http://www.linuxdiyf.com/linux/1236.html