I'm trying to create a script that will kill a process and confirm the process is running before issuing the kill -9 command, I'm running into a bug where it always assumes there is output.
#!/bin/sh
rc=$?
#Ask to check for a process to kill
clear
echo "Please enter a process number you would like to kill"
echo ""
read proc
ps -ef | awk '{print $2}' | grep *$proc*
if [[ $rc != 0 ]]; then
echo "Process not running or already killed"
sleep 2
exit $rc
else
clear
echo "Killing process..."
sleep 2
# kill -9 $proc
fi