Hello. I am trying to put together a ksh script that will perform actions on files based on what type they are. The types would be compressed, zipped, or PCL. I think my test conditions are ok, but I'm a little unsure about how to put it all together. I've come up with this, which does not work...
for A in `ls -1 $DIR1`
do
if [ `file $A | grep -c 'ZIP archive'` -ge 1 ]; then
mv $A $ZIPDIR;
if [ `file $A | grep -c 'compressed'` -ge 1 ]; then
mv $A $ZDIR
if [ `grep -c 'LANGUAGE=PCL'` -ge 1 ];then
mv $A $PCLDIR
fi
fi
fi
done
I get the feeling that this is fairly sloppy and there MUST be a way to do this better (and works).