Re: parsing ps -ax output and killing processes
From: Michael Wang (mwang_at_unixlabplus.com)
Date: 02/15/05
- Next message: Rob: "Re: parsing ps -ax output and killing processes"
- Previous message: Michael Wang: "trap "<new trap action>; $(get_old_trap SIGNAL)" SIGNAL"
- In reply to: Icarus Sparry: "Re: parsing ps -ax output and killing processes"
- Next in thread: Villy Kruse: "Re: parsing ps -ax output and killing processes"
- Reply: Villy Kruse: "Re: parsing ps -ax output and killing processes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Rob: "Re: parsing ps -ax output and killing processes"
- Previous message: Michael Wang: "trap "<new trap action>; $(get_old_trap SIGNAL)" SIGNAL"
- In reply to: Icarus Sparry: "Re: parsing ps -ax output and killing processes"
- Next in thread: Villy Kruse: "Re: parsing ps -ax output and killing processes"
- Reply: Villy Kruse: "Re: parsing ps -ax output and killing processes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]