Help with troubleshooting a Bash Shell script : variable not printed

In the script further below (sorry my browser currently can't attach file due to some issue), the line
below (which is supposed to increment/count the number of files scanned) did not output anything
to the logfile  update.log.  What happened?
   echo "$var "files have been checked." >> /opt/avscan/update.log

I insert the line below because for every file the scanner scanned, it output one line that contains
these strings to update.log causing update.log to become too big:
... $scanfile -NC -l=/opt/avscan /tmp/scan |grep -v "libvsapi.so" |grep -v "+-------" |grep -v "             | " |grep -v "been check" >> ...

======================= Shell script to run AV scan ==================================
var=0
for scanfile in `find /* -type f -size -52428800c -print |grep -v ".sock" |grep -v "/cdrom" |grep -v "/boot" |grep -v "/platfo" |grep -v "/proc" |grep -v mnttab |grep -v "/sys" |grep -v "/dev" |grep -v "/net" |grep -v ".dbf" |grep -v ".arc" |grep -v ".lock" |grep -v ".ctl" |grep -v ".rdo" |grep -v "racle" |grep -v "ysql" |grep -v sulog |grep -v syslog |grep -v messages `; do
    ((var=var+1))
    cd /opt/avscan; nice ./vscan -p=/opt/avscan $scanfile -NC -l=/opt/avscan /tmp/scan |grep -v "libvsapi.so" |grep -v "+-------" |grep -v "             | " |grep -v "been check" >> /opt/avscan/update.log 2>> update.log
done
echo "$var "files have been checked." >> /opt/avscan/update.log
echo "Scan completed on " `date` >> /opt/avscan/update.log
echo "===================" >> /opt/avscan/update.log
sunhuxAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
Did you mean
echo "$var files have been checked." >> /opt/avscan/update.log
?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jmcgOwnerCommented:
The way you have it posted here, that line has unmatched quotes and would create a diagnostic sent to STDERR instead of what you wanted to STDOUT.
sunhuxAuthor Commented:
Thanks guys, there's an extra  "

So Ozo's right, it should be:
echo "$var files have been checked."  >> /opt/avscan/update.log
sunhuxAuthor Commented:
I'll test it out tomorrow
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.