- 论坛徽章:
- 2
|
回复 1# hbmhalley
The standard output of command is connected via a pipe to the standard
input of command2. This connection is performed before any redirec‐
tions specified by the command (see REDIRECTION below). If |& is used,
the standard error of command is connected to command2's standard input
through the pipe; it is shorthand for 2>&1 |. This implicit redirect‐
ion of the standard error is performed after any redirections specified
by the command.
- 第一个, cmd1 的输出传给了 cmd2
- i=0;while :; do echo 3; done | while read line; do echo $line "pipeline"; ((i++)); [[ $i -gt 3 ]] && exit; done
- 第二个, 由于cmd1 的输出重定向为标准错误,cmd2没有接受的任何输入
- i=0;while :; do echo 3 >&2; done | while read line; do echo $line "pipeline"; ((i++)); [[ $i -gt 3 ]] && exit; done
- 第三个, 这个可以以用上面quote部分介绍,
- i=0;while :; do echo 3 >&2; done |& while read line; do echo $line "pipeline"; ((i++)); [[ $i -gt 3 ]] && exit; done
复制代码 |
|