How do I conditionally redirect the output of a command to /dev/null?

前端 未结 4 1587
不思量自难忘°
不思量自难忘° 2020-12-31 04:51

I have a script. I would like to give this script a quiet mode and a verbose mode.

This is the equivalent of:

if $verbose
then
  redirect=\"> /dev         


        
4条回答
  •  北海茫月
    2020-12-31 05:40

    Not perfect, but how about setting redirect to either "/dev/null" or "/dev/tty", and then doing

    {
       echo "verbose"
        ....
    } > $redirect
    

提交回复
热议问题