determine if output is stdout or stderr

solution

  • redireciton
    • standard input: 0
    • standard output: 1
    • standard error: 2
  • print STDERR in red
    1
    bash func 2> >(while read line; do echo -e "\e[01;31m$line\e[0m" >&2;done)
实验楼
实验楼

references