To know the exit status of the elements of a pipeline
cmd1 | cmd2 | cmd3
bash
The exit codes are provided in the PIPESTATUS special array.
cmd1 exit code is in ${PIPESTATUS[0]}, cmd3 exit code in
${PIPESTATUS[2]}, so that $? is always the same as
${PIPESTATUS: -1}.
SHELL中如何获得管道前面的命令的返回值
时间:2015-9-1|作者:
|评论:No Responses|点击:|