Bash: log stdout and stderr while preserving order and provenance

后端 未结 2 376
暗喜
暗喜 2020-12-18 16:09

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

2条回答
  •  情话喂你
    2020-12-18 16:26

    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 tx1
    

    your color() function breaks order because sed is buffering...

提交回复
热议问题