Hi guys,
I'm sorry but i badly need your help. I am assigned to do a basic shell script in my job but sadly i don't have any idea on what it is because i am an electronics engineer, but i googled all of it, ask my friends but i cant finalize my scripts. so do please help me.
The requirement is i hve to do a shell script in unix solaris that will check invalid files in the directory. when there is an invalid file. it will echo "there is an invalid file in this directory(=the directory itself) please see dummyevents.log." then is no invalid file there. it will echo"there is no invalid file in this directory(=the directory itself)". then it will not produce dummyevents.log
how will you knwo that it is invalid file? ihave list of words like. if there is no "apple" word inside the file in the directory. it is invalid.
i hope you understand guys. and please see below draft of my scripts.
apple_DIR=/home/cfg/dirAPPLE.cfg
banana_DIR=/home/cfg/dirBANANA.cfg
orange_DIR=/home/cfg/dirORANGE.cfg
RESULT=/home/
apple_file=`cat $APPLE_DIR`
banana_file=`cat $BANANA_DIR`
orange_file=`cat $ORANGE_DIR`
#apple
for a in $apple_file
do
cd $a
touch Statuscheck.tmp
ls -lrt | grep -l apple > Statuscheck.tmp
FILE=`cat Statuscheck.tmp | wc -l`
if [ $FILE -ne 0 ]
then
echo "Invalid file in $a directory" > $RESULT/dummyevents.log
fi
rm Statuscheck.tmp
done
#banana
for b in $banana_file
do
cd $b
touch Statuscheck.tmp
ls -lrt | grep -l banana > Statuscheck.tmp
FILE=`cat Statuscheck.tmp | wc -l`
if [ $FILE -ne 0 ]
then
echo "Invalid file in $b directory" > $RESULT/dummyevents.log
fi
rm Statuscheck.tmp
done
#orange
for c in $orange_file
do
cd $c
touch Statuscheck.tmp
ls -lrt | grep -l orange > Statuscheck.tmp
FILE=`cat Statuscheck.tmp | wc -l`
if [ $FILE -ne 0 ]
then
echo "Invalid file in $c directory" > $RESULT/dummyevents.log
fi
rm Statuscheck.tmp
done