After something like first_command | … | last_command & $! is set to the PID of last_command. How can I find the other PIDs in this pipeline? Especially, is there a convenient way to find the PID of the second to last command? I can look in /proc/$!/fd/0 and grep for the pipe number in ls /proc/*/fd/1, but that isn't exactly reliable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.