假设我从以下语句开始,它将字符串echo
到网络上:
$ echo "foo" 1>/dev/null
我将提交以下流程:
然后,我会提交以下流程:
$ echo "foo" | cat -e - 1>/dev/null
然后我将这个过程省略:
$ echo "foo" | 1>/dev/null
为什么没有返回错误信息?关于bash和管道的文档似乎并没有直接提到可能的原因。在
echo
(或者运行在管道上游的进程)第一次读取之前有没有发送EOF信号?variable assignments apply to the current execution environment. The following will set two variables to argument values:
arg1=$1 arg3=$3
redirections occur in a subshell, but the subshell doesn't do anything other than initialize the redirect. The following will truncate or create the indicated file (if you have appropriate permissions):
>/file/to/empty
:
)。本答案摘自 Posix XCU§2.9.1。