It\'s fairly simple to log both the stdout and the stderr of a command to a log file:
./foo.sh &> log.txt
The problem is that when i
maybe you are looking for script it records both stdout, stderr and the commands...it starts a new shell in which it records everything (or use -c _cmd_)
script
-c _cmd_
$ script tx1
your color() function breaks order because sed is buffering...
color()
sed