How can I hide the output of a shell application in Linux?
How can I hide the screen output (printf) of a shell application in Linux?
You can redirect the output of any program so that it won't be seen.
$ program > /dev/null
This will redirect the standard output - you'll still see any errors
$ program &> /dev/null
This will redirect all output, including errors.
There are three I/O devices available on the command line.
standard input - 0
standard output - 1
standard error - 2
To redirect standard output (the default output) to a file (and overwrite the file), use
command > file.log
To append to file.log, use two >
s
command >> file.log
To redirect standard error to the file.log, use
command 2> file.log
And to append
command 2>> file.log
To combine the outputs into one stream and send them all to one place
command > file.log 2>&1
This sends 2 (standard error) into 1 (standard output), and sends standard output to file.log
Notice that it's also possible to redirect standard input into a command that expects standard input
command << file.txt
For more details, check out the Advanced Bash Scripting Guide.