pipelines和重定向命令

来源:互联网 发布:java项目案例分析 编辑:程序博客网 时间:2024/05/18 02:47

pipelines:

command1 | command2

例如,ls -l /usr/bin | less,将输出结果作为 less 命令的输入结果,在standard output 中显示出来。

管道命令 “|” 和重定向命令 “>” 的区别

the redirection operator connects a command with a file while the pipeline operator connects the output of one command with the input of a second command.

也就是说,重定向连接的是命令和文件,管道连接的是命令和命令。以下为例:

# cd /usr/bin# ls > less

这条命令的实际效果是:/usr/bin目录下的 less 文件会被 ls命令的输出结果所覆盖掉,而不是把 ls 命令的输出结果显示在屏幕上 (less 命令)。
因此,如果命令文件重名,可能发生意想不到的结果。

原创粉丝点击