Create a gist now

Instantly share code, notes, and snippets.

@v6ak /exp.sh
Created Dec 5, 2015

Embed
What would you like to do?
Processing of stderr without merging it with stdout
#!/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