>与>>重定向

1.在linux中,使用> 和 >> 可使数据流重定向。linux

如:bash

ll / > ~/files;file

在终端中并不显示全部的文件,而是会将查到的目录写入到 ~/files中。终端

> 是替换, >> 是向后累加。error

使用 cat ~/files 能够查看数据。数据

当没有 files 文件,会自动建立文件并写入。重定向

2. 标准输出 stdout (standard output):代码为 1文件

    标准错误输出 stderr (standard error output):代码为 2 .错误

在执行命令时,能够将正确和错误的代码分别写入到不一样的文件中

如:

find /home -name .bashrc > list_right 2> list_error

3.数据不进行写入操做,定向到/dev/null

find /home -name .bashrc > /dev/null 2> list_error

4.将正确和错误的写入到同一个文件

find /home -name .bashrc > list 2>&1

相关文章
相关标签/搜索