Reputation: 7023
I've written the following script to kill processes named "client" and "server". When I run it I get:
: No such file or directory
The script is:
#!/bin/bash
function killThem {
while read -a line; do
kill -9 ${line[0]}
done
}
ps | grep -w client | cut -d" " -f1 | killThem
ps | grep -w server | cut -d" " -f1 | killThem
Does anyone have any idea why I get this error?
Upvotes: 0
Views: 107
Reputation: 952
you are reinventing killall but anyway:
kill -9 ${line[0]}
should be
kill -9 ${line}
Upvotes: 3