0:stdin标准输入
1:stdout标准输出
2:stderr标准错误输出
>:标准输出重定向
2>:标准错误输出重定向
>>:标准输出追加重定向
2>&1:标准错误输出转化为标准输出再重定向
>& 或 &>:标准输出和标准错误输出都重定向
| tee:tee管道,输出到前台的同时重定向到指定文件
| tee -a:tee管道,输出到前台的同时追加重定向到指定文件
用法:
#who > who.out
#who | tee who1.out
#w >> who.out
#cd /root/shell
#ls z* > err.out
#cat err.out
#ls z* 2> err.out
#a 2 >> err.out
#cat < err.out
#sh install.sh &> install.log
#sh install.sh 2>&1 | tee -a install.log
cat < file1
cat <<-EOF > file2
111
222
333
EOF