Passing multiple arguments to a UNIX shell script

Posted by Waffles on Stack Overflow See other posts from Stack Overflow or by Waffles
Published on 2010-12-24T20:48:18Z Indexed on 2010/12/24 21:54 UTC
Read the original article Hit count: 307

Filed under:
|
|
|

I have the following (bash) shell script, that I would ideally use to kill multiple processes by name.

#!/bin/bash
kill `ps -A | grep $* | awk '{ print $1 }'`

However, while this script works is one argument is passed:

end chrome

(the name of the script is end)

it does not work if more than one argument is passed:

$end chrome firefox

grep: firefox: No such file or directory

What is going on here?

I thought the $* passes multiple arguments to the shell script in sequence. I'm not mistyping anything in my input - and I the programs I want to kill (chrome and firefox) are open.

Any help is appreciated.

© Stack Overflow or respective owner

Related posts about bash

Related posts about shell