I've got the following command:
$ cmd-a | while read -r line; do echo "${line}"; cmd-b; done
This works well, and will for all intents and purposes look like cmd-a
is just printing its stdout as normal, but for each line we execute cmd-b
as well.
Is there a cleaner way to do this?
cmd-a | xargs -n1 cmd-b
would be nice, but it splits on all whitespace (I know GNU xargs has the -d
option, but it's unfortunately not available to me,) and would suppress the output of cmd-a
.