How to silence output in a Bash script?

后端 未结 9 2064
离开以前
离开以前 2020-11-29 17:15

I have a program that outputs to stdout and would like to silence that output in a Bash script while piping to a file.

For example, running the program will output:<

9条回答
  •  旧时难觅i
    2020-11-29 17:56

    Useful in scripts:


    Get only the STDERR in a file, while hiding any STDOUT even if the program to hide isn't existing at all (does not ever hang parent script), this alone was working:

    stty -echo && ./programMightNotExist 2> errors.log && stty echo
    

    Detach completely and silence everything, even killing the parent script won't abort ./prog :

     ./prog /dev/null 2>&1 &
    

提交回复
热议问题