Hi all,
I am using an if condition to compare the word count of a file to be equal to 21.If the file is equal(having 21 words),it is working correct.The problem is that if the file is having different word count than 21 also it is going inside the if loop.I tried using = also instead of -eq.Still no go.Any inputs on this?

Thanks,
Floyd

wordcount=`head -1 $dir/$file1 | wc -w`
echo "WC is $wordcount"
dbwordcount=21

if [ wordcount -eq dbwordcount ]; then
echo "Word are matching $wordcount $dbwordcount"
else
echo "Words not matching $wordcount"
fi

> if [ wordcount -eq dbwordcount ]; then
Use some $, like your other variable references.

How!!!Oversight...I missed that silly thing and was wondering what is going wrong.!! O! God...
Thanks buddy Thanks a lot for the findings.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.