:
{
command1
command2
} >/dev/null
- script - , exec builtin:
echo interesting
exec >/dev/null
echo boring
, script, . , .
exec /dev/null, . , . , , , , , , .
{
exec 3>&1 # duplicate fd 3 to fd 1 (standard output)
exec >/dev/null # connect standard output to /dev/null
echo boring
exec 1>&3 # connect standard output back to what was saved in fd 3
echo interesting
exec >/dev/null # connect standard output to /dev/null again
echo more boring
} 3>/dev/null # The braced list must have its fd 3 connected somewhere,
# even though nothing will actually be written to it.
source
share