linux shell重定向总结

时间:2023-03-09 08:17:09
linux shell重定向总结
command-line1 [-n] > file或文件操作符或设备

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

ls test.sh test1.sh >suc.txt >err.txt
ls test.sh test1.sh >>suc.txt >>err.txt exec >&- exec <&- &[n] 代表是已经存在的文件描述符,& 代表输出 &2代表错误输出 &-代表关闭与它绑定的描述符 ls test.sh test1.sh &>/dev/null
#& 代表标准输出 ,错误输出 将所有标准输出与错误输出 输入到/dev/null文件
command-line [n] <file或文件描述符&设备

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