4-3 管理及IO重定向

1. 系统设定默认输出设备:标准输出(STDOUT,1)

    系统设定默认输入设备:标准输入(STDIN,0)

    系统设定默认错误设备:标准错误(STDERR,2)

 

2. 标准输入:键盘

     标准输出和错误输出:显示器

 

3. 输出

覆盖输出

符号:>

注意使用这个>,会覆盖之前的内容

image

 

追加输出

符号: >>

它不会覆盖之前的内容,只会在之前的内容往下写

image

 

4. set 是功能开关设置

set  +C:开复写

set   -C:关复写

-C      If set, bash does not overwrite an existing file with the >, >&, and <> redirection operators.  This may be overridden when creating output files by using the
                     redirection operator >| instead of >.

刚刚关闭了复写功能,但是>>功能还是有效,原因就是这个功能只对 >,>&,<>有用

image

不过,可以强制输出,用 >|

image

5. 错误输出

2> :重定向错误输出,只能对错

2>>:追加方式

image

 

 

6. &>:上面讲的是重定向标准输出或错误输出至同一个文件,这个我没有演示成功。

 

7. 输入重定向

格式:<

没有整明白啊

image

有个概念还是没有整明白

<<:说是here document

EOF:end  of    file

 

8. 管道

概念:前一个命令的输出作为后一个命令的输入

另外,echo命令的功能是在显示器上显示一段文字,一般起到一个提示的作用,先不做详细说明。

image

 

 

9. tee功能

tee - read from standard input and write to standard output and files

功能:tee将数据保存文件和显示器

其中有个管道的概念。不错。

image

 


 

 

 

 

 

原文地址:https://www.cnblogs.com/BlackWizard2016/p/6238359.html