How to silence output of all commands in a Bash script?
You can use the exec
command to redirect everything for the rest of the script.
You can use 3>&1
to save the old stdout stream on FD 3, so you can redirect output to that if you want to see the output.
exec 3>&1 &>/dev/null
some_command
another_command
command_you_want_to_see >&3
command3