remove_old_programs.bash 547 Bytes
Newer Older
Rohit Gupta's avatar
Rohit Gupta committed
1
2
3
#!/bin/bash

#$1 programs to be killed and checked
4
5
echo "removing old programs..."
echo "args = $1"
6
7
echo "script name = $0"
filename=$(basename "$0")
Rohit Gupta's avatar
Rohit Gupta committed
8
echo "programs to be killed"
9
10
11
12
echo "bash PID = $$"
pid='$$'
#we need to remove current program and grip as we kill ourselves otherwise :)
var=`ps -aux |grep -E -i $1 | awk '{print $2}'`
Rohit Gupta's avatar
Rohit Gupta committed
13

14
15
16
echo $var

echo "$var" | sed 's/'$$'/ /' | sudo xargs kill -9
Rohit Gupta's avatar
Rohit Gupta committed
17

18
var=`ps -aux |grep -E -i $1| grep -E -v '$filename|grep|$$'`
Rohit Gupta's avatar
Rohit Gupta committed
19
20
21
echo $var
if [ -n "$var" ]; then echo 'Match found'; else echo 'Match not found' ;fi