title: Redirect output for commands based on state of variable
body: <p>I have many commands in a bash script that have <code>&gt;/dev/null 2&gt;&amp;1</code> used to redirect stdout and stderr to /dev/null.</p>
  
  <p>Let us say I have a variable called <code>echoOn</code>, which can be either 0  or 1.</p>
  
  <p>If <code>echoOn</code> is equal to 0, then I wish to keep the redirections on the commands in the script. If it is equal to 1, then I do not want the redirection in place, so the commands are able to output.</p>
  
  <p>I do not wish to suppress the output of all commands but only specific ones within the script.</p>
  
  <p>Is there a more abstract way for me to do this without manually adding if statements to every command in question?</p>
  
  <p>I am open to having a function in which I pass the command and its arguments and replacing each command with a call to the aforementioned function and the command to be executed.</p>