linux shell重定向总结

 

command-line1 [1-n] > file或文件操作符或设备

command-line1 [1-n] >> file或文件操作符或设备



ls test.sh test1.sh 1>suc.txt 2>err.txt
ls test.sh test1.sh 1>>suc.txt 2>>err.txt

exec 3>&- 

exec 3<&- 

&[n] 代表是已经存在的文件描述符,&1 代表输出 &2代表错误输出 &-代表关闭与它绑定的描述符



ls test.sh test1.sh &>/dev/null
#& 代表标准输出 ,错误输出 将所有标准输出与错误输出 输入到/dev/null文件

 

 

command-line [n] <file或文件描述符&设备



cat>catfile <<eof
test a file
eof
#<< 这个连续两个小符号, 他代表的是『结束的输入字符』的意思。这样当空行输入eof字符,输入自动结束,不用ctrl+D

 

posted @ 2016-04-07 11:11  fyzjhh  阅读(151)  评论(0编辑  收藏  举报