You are not logged in.

#1 2008-01-21 15:41:02

dax965
Member
Registered: 2007-09-09
Posts: 35

Bash script

#!/bin/sh
prcs = pgrep $1
kill $prcs

How do I make a script that does that (my unworking version should show what I'm trying to do)

Offline

#2 2008-01-21 15:49:50

pressh
Developer/TU
From: Netherlands
Registered: 2005-08-14
Posts: 1,719

Re: Bash script

Is this behavior what you're looking for ?

#!/bin/bash
kill $(pgrep $1)

[edit]
I hope it is not your homework ? tongue

Last edited by pressh (2008-01-21 15:52:08)

Offline

#3 2008-01-21 15:54:50

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: Bash script

After a man pgrep, I see it's symlinked to pkill!
pkill is what you want!

no need for the script, just "pkill hto" will kill all htop e.g.

Offline

#4 2008-01-21 15:56:31

dax965
Member
Registered: 2007-09-09
Posts: 35

Re: Bash script

pressh wrote:

Is this behavior what you're looking for ?

#!/bin/bash
kill $(pgrep $1)

[edit]
I hope it is not your homework ? tongue

Thanks, yeah that works.  It isn't my homework, wink


Gilneas wrote:

After a man pgrep, I see it's symlinked to pkill!
pkill is what you want!

no need for the script, just "pkill hto" will kill all htop e.g.

Even better!  Thanks.

Offline

Board footer

Powered by FluxBB