SHELL中如何获得管道前面的命令的返回值

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}.

请选择你看完该文章的感受:

0不错 0超赞 0无聊 0扯淡 0不解 0路过

随机文章:

发表评论