Let’s suppose I have a bash script (foo.sh) that in a very simplified form, looks like the following:
echo 'hello' sleep 100 & ps ax | grep sleep | grep -v grep | awk '{ print $1 } ' | xargs kill -9 echo 'bye'
The third line imitates pkill, which I don’t have by default on Mac OS X, but you can think of it as the same as pkill. However, when I run this script, I get the following output:
hello foo: line 4: 54851 Killed sleep 100 bye
How do I suppress the line in the middle so that all I see is hello and bye?
How about disown? This mostly works for me on Bash on Linux.
Edit: Matched the poster’s code better.