This answer shows numerous ways to stream multiple commands into another command, but since they use subshells you can't do stdin.
While you can achieve this with named pipes, it's somewhat ugly and can leave leftover processes afterwards:
$ mkfifo p $ while :; do sleep 5s; echo save; done > p & $ cat p > output & $ cat </dev/stdin > p test asdf woot ^C $ cat output save test asdf save save woot save $ jobs - Running while :; do sleep 5s; echo save; done > p & + Running cat p > output &
Is there a way to pull this off in a single command? Ideally I would like something along the lines of:
someutil <(while :; do sleep 5s; echo save; done) /dev/stdin > output
This way I can pipe the output to another command instead of a file.