I pipe the same content to multiple commands with
tee, subshells and redirects like this:
#!/usr/bin/env bash echo 'hello' | tee \ >( sleep 3; cat /dev/stdin ) \ >( sleep 2; cat /dev/stdin ) \ >( sleep 1; cat /dev/stdin ) wait # Doesn't work :(
However, what I see is that the subshell output is written to the terminal after the main script exits and
wait doesn't work:
$ ./test.sh hello $ hello hello hello
How to properly wait for the subshells?