I have a bash script that runs a program with parameters. That program outputs some status (doing this, doing that...). There is no option for this program to be quiet. How can I prevent the script from displaying anything?
I am looking for something like windows "echo off".
Take a look at this example from The Linux Documentation Project:
That said, you can use this simple redirection:
The following sends standard output to the null device (bit bucket).
and if you also want error messages to be sent there, use one of (the first may not work in all shells):
and, if you want to record the messages but not see them, replace
/dev/null
with an actual file, such as:For completeness, under Windows cmd.exe (where "nul" is the equivalent of "/dev/null"), it is :
Try
:
is short for "do nothing".$()
is just your command.In you script you can add the following to the lines that you know are going to give an output:
Or else you can also try
Something like
This will prevent standard output and error output, redirecting them both to
/dev/null
.An alternative that may fit in some situations is to assign the result of a command to a variable:
Since Bash and other POSIX commandline interpreters does not consider variable assignments as a command, the present command's return code is respected.