Re: parsing ps -ax output and killing processes

From: Michael Wang (mwang_at_unixlabplus.com)
Date: 02/15/05


Date: Tue, 15 Feb 2005 12:57:10 GMT

In article <U6mQd.6906$m31.86596@typhoon.sonic.net>,
Icarus Sparry <usenet@icarus.freeuk.com> wrote:
>tokill=$(ps -ax | grep -- "$1" | grep -v grep | awk '{print $1}')
>if [[ -n $tokill ]]
>then
> kill $tokill
>fi

The first line could simplified as

tokill=$(ps -ax | awk "/[${1:0:1}]${1:1}/ { print \$1 }")

-- 
For low fair air travel, take Independence Air - http://www.flyi.com/.
Michael Wang * http://www.unixlabplus.com/ * mwang@unixlabplus.com