linux 数据流重导向
传输的命令如下:
1.标准输入(stdin):代码0,使用<或<<
2.标准输出(stdout):代码1,使用>或>> (>>表示不被覆盖)
3.标准错误输出(stderr):代码2,使用 2> 或2>>
例
<1>将数据输出到不同的地方
$ find /home/ -name testing >list_right 2>list_error (若文件不存在则创建)
<2>只要正确的数据,不要错误信息。
$ find /home/ -name testing >list_right 2>/dev/null
其中/dev/null是个虚拟的垃圾桶设备
<3>将数据写入到同一个文件中的特殊写法
$ find /home/ -name testing >list 2>&1
<4>使用其他文件来替换键盘输入
$cat >catfile <somefile
<5> "<<"表示结束的输入字符
$ cat >catfile <<eof
传输的命令如下:
1.标准输入(stdin):代码0,使用<或<<
2.标准输出(stdout):代码1,使用>或>> (>>表示不被覆盖)
3.标准错误输出(stderr):代码2,使用 2> 或2>>
例
<1>将数据输出到不同的地方
$ find /home/ -name testing >list_right 2>list_error (若文件不存在则创建)
<2>只要正确的数据,不要错误信息。
$ find /home/ -name testing >list_right 2>/dev/null
其中/dev/null是个虚拟的垃圾桶设备
<3>将数据写入到同一个文件中的特殊写法
$ find /home/ -name testing >list 2>&1
<4>使用其他文件来替换键盘输入
$cat >catfile <somefile
<5> "<<"表示结束的输入字符
$ cat >catfile <<eof