Hacker News new | past | comments | ask | show | jobs | submit login

In bash, you can get the rc of piped things, the var eludes me while walking..



${PIPESTATUS[@]} for a space delimited list of all exit codes, or replace @ with the position in the pipe chain of the specific command you want.

ps auxwww | grep banana | grep -v grep && echo ${PIPESTATUS[1]}

type of thing


You can also set -o pipefail. The first non-zero exit code is returned if there is one.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: