# Set debug flag as desired DEBUG=1 # DEBUG=0 if [ "$DEBUG" -eq "1" ]; then OUT='/dev/tty' else OUT='/dev/null' fi # actual script use commands like this command > $OUT 2>&1 # or like this if you need command 2> $OUT