Linux shell : 管道 |

概念

意义

理解

用法

返回值

PIPESTATUS

An array variable (see Arrays) containing a list of exit status values from the processes in the most-recently-executed foreground pipeline (which may contain only a single command).

上面是gnu中的定义。可以看成PIPESTATUS是个一维数组,它中保留 最近执行的运行在前台 的管道的退出码。也就是说,后台的,或者管道之后又执行了其他命令,则PIPESTATUS就被清空或覆盖了。

以下我通过几个例子来下效果。

function a { return 1 } 

function b { return 2 }

function c { return 3 }

a | b | c 

echo PIPESTATUS

echo 

本篇文章出自“国民时代”,转载请注明转载出处。
原文地址:https://www.cnblogs.com/ChinaGo/p/9900515.html