From b3a93bc128f9918bd6c60b7571ba4c81006626cd Mon Sep 17 00:00:00 2001 From: Cedric Dufour Date: Fri, 4 Sep 2015 10:16:54 +0200 Subject: [PATCH] Retrieve N-th piped command exit status --- cheat/cheatsheets/bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cheat/cheatsheets/bash b/cheat/cheatsheets/bash index 5b7a702..c19f599 100644 --- a/cheat/cheatsheets/bash +++ b/cheat/cheatsheets/bash @@ -18,3 +18,7 @@ set -x # Turn off debugging: set +x + +# Retrieve N-th piped command exit status +printf 'foo' | fgrep 'foo' | sed 's/foo/bar/' +echo ${PIPESTATUS[0]} # replace 0 with N