Complete.Org: Mailing Lists: Archives: discussion: March 2000:
[aclug-L] Re: script to kill
Home

[aclug-L] Re: script to kill

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: discussion@xxxxxxxxx
Subject: [aclug-L] Re: script to kill
From: Carl D Cravens <raven@xxxxxxxxxxx>
Date: Wed, 22 Mar 2000 15:16:05 -0600 (CST)
Reply-to: discussion@xxxxxxxxx

On Wed, 22 Mar 2000 glandix@xxxxxxxxxxxxxx wrote:

> ok, i've got this working, but how do i fit the kill command with it? 
> i tried what i thought would be correct, but it killed my term, too... 

> > ps e |awk '$5 ~ /PROG/ {print $1}'

Huh.  What are you substituting for PROG?  Do note that the /x/ function
of awk is a regular expression match... if you search for something like
/sh/, it'll find bash, ksh, sh, fish, shell, etc.  So if you're searching
for something common, you'll have to be careful to write the pattern to be
as specific as possible.  

By putting back-ticks around the command, you can substitute the command's
output on the command line... 

kill `ps e |awk '$5 ~ /PROG/ {print $1}'`

...which is probably what you did.  

Make sure that 'ps e' produces the output your expecting and that the name
of the program is listed in the fifth space-separated word.  (The $5 is
looking at that word.)  It's possible that the various Linux distros may
use different flavors of ps.  (And ps has got to be one of the most widely
varied commands among the various flavors of Unix.  Flags and output
differ greatly.)  

--
Carl D Cravens (raven@xxxxxxxxxxx)
Don't do dat, it hurts my wittle bwain.


-- This is the discussion@xxxxxxxxx list.  To unsubscribe,
visit http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi


[Prev in Thread] Current Thread [Next in Thread]