I like @BroSlow's answer best. Another way to redirect stdout and stderr
echo before
# turn off stdout and stderr
# (but save their currect locations first)
exec 3>&1 1>/dev/null
exec 4>&2 2>/dev/null
echo no
echo error >&2
echo output
# restore stdout and stderr
# and close the temp file descriptors
exec 1>&3 3>&-
exec 2>&4 4>&-
echo after
echo after error >&2
You'll see the "before" and "after" stuff, but not the output in the middle.