If, in bash, I execute:
cmd1 | cmd2 | cmd3... | cmdi | ... | cmdn &
where the cmd{1..n} may not be distinct, how do I get the PID of cmdncmdi? Alternatively, how can I signal the cmdncmdi process? (For example, send it SIGUSR1?)
pkill/pgrep, pidof etc. don't look like good answers, since other instances of cmdncmdi maybe running, including as part of the same pipeline. jobs -p gives the PID of cmd1, for me.
i can be anything in {1..n}.