Sunday, April 9, 2017

find list of firefox processes and terminate shell script


#!/bin/bash
output=$(ps -ef|grep firefox)
linesCount=0;
while read lines;do
((linesCount++));
echo "$lines";

word=$(echo $lines | tr " " "\n");
wordCount=0;
for wordArr in $word;do
((wordCount++));

if [ $wordCount -eq 2 ]
then
kill -9  $wordArr;
fi
done





done<<<"${output}"

No comments:

Post a Comment