The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ypbind - multiple instances starting blowtorch SUN Solaris 0 10-01-2007 03:51 AM
detecting multiple instances ragha81 Shell Programming and Scripting 3 04-06-2007 07:09 AM
Creating instances of a program tushar_johri Shell Programming and Scripting 2 05-25-2005 07:36 AM
Multiple file instances gozer13 UNIX for Dummies Questions & Answers 1 12-29-2004 04:08 PM
multiple instances of syslogd - is it possible? Gary Dunn UNIX for Advanced & Expert Users 9 07-20-2004 06:10 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 12-16-2007
Registered User
 

Join Date: Nov 2007
Posts: 18
try this

kill `ps -ef |awk '/xterm/ && !/'$$'/' | awk '{print $2}'`
Reply With Quote
Forum Sponsor
  #9  
Old 12-16-2007
Jmt
Guest
 

Posts: n/a
here's how I do it

ps aux | grep $1 | awk '{system("kill " $2);}'

I put this in a script named KillAll, then call the script with the string I want to filter for. But, be careful, it doesn't care where it finds your search string, it will kill anything with the string anywhere in the results of ps aux. The script could be easily improved.

-Jmt
Reply With Quote
  #10  
Old 12-16-2007
Registered User
 

Join Date: Nov 2007
Posts: 18
This may work

kill `ps -ef |awk '/xterm/ && !/'$$'/' | awk '{print $2}'`
Reply With Quote
  #11  
Old 12-16-2007
Registered User
 

Join Date: Aug 2005
Location: in my heart. ..kidding. Calcutta, India.
Posts: 13
JMT and Kundunni,

thank you both a lot for your replies. I'll try your solutions as soon as I get to my work.

I am sure JMT's solution will work since I understand what his command exactly does.

But kundunni, I'd highly appreciate it if you explain your command.

BTW, seeing your posts.. I'm thinking is this:
kill -9 `ps -fu | grep "xterm" | awk '{print $2}'`
would work?

awaiting your reply.

Regards
Indrajit
Reply With Quote
  #12  
Old 12-16-2007
Registered User
 

Join Date: Mar 2005
Posts: 2
In ksh:

ps -eaf | grep xterm | grep -v grep | while read a b c ; do
kill $b
done
Reply With Quote
  #13  
Old 12-16-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
Quote:
kill -9 `ps -fu | grep "xterm" | awk '{print $2}'`
Don't you have to specify the username along with ps -fu ?

Code:
ps -fu $USER
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0