#!/bin/bash PREF="$1" shift NPOUT=pipe.out NPERR=pipe.err mkfifo $NPOUT $NPERR # Make two background sed processes sed "s/^/$PREF/" <$NPOUT & sed "s/^/$PREF/" <$NPERR >&2 & # Run the program "$@" >$NPOUT 2>$NPERR rm $NPOUT $NPERR