| #!/bin/bash | |
| # prepare queues | |
| d=$(mktemp -d) | |
| o="$d/out" | |
| e="$d/err" | |
| mkfifo "$o" | |
| mkfifo "$e" | |
| # cat the queues to outputs | |
| cat "$o"& | |
| outpid=$! | |
| cat "$e" | sed 's#^#[err] #'> /dev/stderr& # you can process the output through pipe… | |
| errpid=$! | |
| # run the command | |
| (echo a > /dev/stdout; echo b > /dev/stderr) > "$o" 2> "$e" | |
| # wait for the outputters | |
| wait $outpid $errpid | |
| # clean it up | |
| rm -r "$d" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment