Append text to stderr redirects in bash
Right now I'm using exec to redirect stderr to an error log with exec 2>> ${errorLog} The only downside is that I have to start each run with a timestamp since exec just pushes the text straight into the log file. Is there a way to redirect stderr but allow me to append text to it, such as a time stamp? This is very interesting. I've asked a guy who knows bash quite well, and he told me this way: foo() { while IFS='' read -r line; do echo "$(date) $line" >> file.txt; done; }; First, that creates a function reading one line of raw input from stdin, while the assignment to IFS makes it doesn't