I'm building a shell script to automatically configure a specific computer with the best settings. I would like to hide all output from this script except for echo output. Is it possible?
Start your script with:
That will save your original file descriptor for stdout to &3, and then redirect stdout and stderr to /dev/null. Whenever you want to print something, redirect its output to &3, like:
And if you want to hide that detail, you can just define a function that echoes to fd 3:
|
|||||
|
You can redirect stdout to
at the end of each line of your script that will produce output. You can redirect errors the same way by adding
Most commands also have an option to turn off normal output to the console like |
||||
|
&> /dev/null
except the echos. – LatinSuD Jun 24 '14 at 13:32