How to silence output in a Bash script?

后端 未结 9 2063
离开以前
离开以前 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条回答
  •  囚心锁ツ
    2020-11-29 18:02

    If you want STDOUT and STDERR both [everything], then the simplest way is:

    #!/bin/bash
    myprogram >& sample.s
    

    then run it like ./script, and you will get no output to your terminal. :)

    the ">&" means STDERR and STDOUT. the & also works the same way with a pipe: ./script |& sed that will send everything to sed

提交回复
热议问题