1

How can I hide all output that is written and outputted in a terminal?

In other words, I am looking to add the string

>/dev/null 2&>1

to every command I write.

  • How would you do it with bash?
  • How would you do it with zsh?
  • Ideally how to have a configuration that take into account any terminal.
2

zsh:

You can redirect stdout and stderr of any following command to /dev/null by running these two command:

exec >/dev/null
exec 2>/dev/null

Note: This will still show the prompt and anything you type on the command line, but not much else.

bash:

You can redirect stdout and stderr with the following command

exec >/dev/null 2>&1

Note

  • This will suppress any output, including the prompt and what you type on the command line.

  • To enable the output again, run

    exec >/dev/tty
    exec 2>/dev/tty
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.