I'm not able to do the thing you want, but I am able to show you another way (roughly same as your original) that will do what you want:
Code:
#!/bin/bash
ALLINPUT="$@"
if [ ! -z "${ALLINPUT}" ]
then
for PROCESS in ${ALLINPUT}
do
ps -aux | egrep -v 'psfind|grep' | grep ${PROCESS}
done
else
echo -e "\npsfind v0.3"
echo -e "\tUsage: psfind process1 process2 ...\n"
fi
$@ holds all that was given to the script.
The
for PROCESS in ${ALLINPUT} will keep working untill all in ${ALLINPUT} is given to the do ..... done loop. So you don't need any counters to check id there are any left.
I also turned around the error part. Why?? this way you have a little speed increase. Most of the times you will give an argument to psfind, so if you check that first you win a few clock sicles
