How can I suppress all output from a command using Bash? How can I suppress all output from a command using Bash? bash bash

How can I suppress all output from a command using Bash?


The following sends standard output to the null device (bit bucket).

scriptname >/dev/null

And if you also want error messages to be sent there, use one of (the first may not work in all shells):

scriptname &>/dev/nullscriptname >/dev/null 2>&1scriptname >/dev/null 2>/dev/null

And, if you want to record the messages, but not see them, replace /dev/null with an actual file, such as:

scriptname &>scriptname.out

For completeness, under Windows cmd.exe (where "nul" is the equivalent of "/dev/null"), it is:

scriptname >nul 2>nul


Something like

script > /dev/null 2>&1

This will prevent standard output and error output, redirecting them both to /dev/null.


Try

: $(yourcommand)

: is short for "do nothing".

$() is just your command.