文件描述符File Descriptor(系统自带)
0 标准输入(stdin) 键盘
1 标准输出(stdout) 显示器
2 标准错误输出(stderr) 显示器
重定向符号
>和>> 输出重定向
&> 表示将一个流重定向到另一个文件描述符
<和<< 输入重定向
输出重定向
command >file ls / 1>test.txt

command >>file echo "wuya" 1>>test.txt(1可以省略)文件追加


标准错误输出重定向(屏蔽错误信息)
command 2>file find / -name "aaa" 2> ~/1111.txt 2>/dev/nell

command 2>>file find / -name "aaa">>err.txt

输出错误和重定向
ls 7.txt 8.txt 1>a.txt 2>b.txt
find /-name "aaa" >test.txt 2>&1 错误信息和正确信息一起加入到test.txt文件中


输入重定向
command < file wc -l < test.txt(world count)

command <<END wc-l << END 从键盘读取数据遇到END停止

浙公网安备 33010602011771号