william-r
10/31/2017 - 9:21 PM

Display and Kill by Process ID

#!/bin/bash
#display the process information for gedit
ps aux | egrep "gedit|PID"
#print the process id and kill gedit
for pid in $(pgrep 'gedit');
do
    echo $pid;
    kill $pid;    
done
#another way to kill gedit
for pad in $(pidof "gedit");
do
    kill $pad;
done