Consider the following (slightly silly) script name 'test1.sh':
#/bin/bash
#
sleep 10 &
echo sleep pid = $!
pkill sleep
When I run it, I get not only the output of the echo, but bash's reporting of the death of sleep on stderr:
$ ./test1.sh
sleep pid = 3551
./test1.sh: line 5: 3551 Terminated sleep 10
In this case, I'd like to suppress the printout to stderr. I know I can do it on the command line, as in:
$ ./test1.sh 2> /dev/null
... but is there a way to suppress it from within the script? (I know I could wrap it in a second script and have the wrapper redirect it, but there must be something easier...)