How do I execute the kill -9 in this perl one liner? I have gotten down to where I have the pids listed and can print it out to a file, like so:
ps -ef | grep -v grep |grep /back/mysql | perl -lane '{print "kill -9 $F[1]"}'
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
OK, heavily edited from my original answer.
First, the straightforward answer:
Done.
But
grep | grep | perlis kind of a silly way to do that. My initial reaction is “Why do you need Perl?” I would normally do it withawk | kill, saving Perl for more complicated problems that justify the extra typing:(Note that the awk won’t find itself because the string “\/back\/mysql” doesn’t match the pattern /\/back\/mysql/)
You can of course use Perl in place of awk:
(I deliberately used leaning toothpicks instead of a different delimiter so the process wouldn’t find itself, as in the awk case.)
The question then switches from “Why do you need perl?” to “Why do you need grep/awk/kill?”: