When a script runs, commands in it may output some text to stdout/stderr. Bash itself may also output some text.
But if a few scripts are running at the same time, it is hard to identify where does an error come from.
So is it possible to insert a prefix to all output of the script? Something like:
#!/bin/bash
prefix 'PREFIX' &2
echo "wrong!" >&2
Then:
$ ./script.sh
PREFIXwrong!
function echo() { /bin/echo $PREFIX$*; }
help you? – Philippos Apr 27 '18 at 13:46[ x -eq 1 ]
caused shell itself reporting error, which this kind of way could not help. – Magicloud Apr 27 '18 at 14:38