I need to omit binary files from a ksh script. I want to pass $VAR to ls which will pipe to grep, here are the two chunks of code I'm trying to write together, the top part doesn't work and I need help...

$LOGS=/mydir

for NONEXEC in `ls -a1 $LOGS/*`
do EXEC1=`file $NONEXEC | grep executable | grep -v script | awk '{ print }'`
done

for DIR in `ls -d $LOGS/* | grep -v image | grep -v wilson | grep -v compare | grep -v refdb`
do

if [[ ! -d $DIR ]]
then
continue
fi