How to get return values from bash pipeline command?

Solution Unverified - Updated -


The customer is running a pipeline command, when using "echo $?", only the return value of last command could be got, how to get the return value from the second command?

# df |awk '{print $5}' |grep /mnt 2>&1 | tee ./log; echo $?


Red Hat Enterprise Linux All Versions

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content