Greetings,
I want to know what the simplist way to check contents of a text file is.
Ie. I have a text file called datatest with the following in it:
Mike
Joe
Blair
I want a script that will check the contents of that file and compare it with a variable I have created in the script. If there is a match for all then it will echo back 'Success'. If not, then it will echo back which were not found.
#!/usr/bin/ksh
count=0
check="Mike Joe Blair"
for namex in $check
do
if grep $namex datatest > /dev/null; then
count='expr $count + 1
echo "$namex found"
fi
done
if [ $count==3 ]; then
echo "Success"
else
echo "Did not find all matches"
fi
I am new at this so sorry if it looks silly. I think the $count=3 is wrong (I want to check the 3 names and if all 3 match the text file datatest then success). Any suggestions? The count works but I can't get the $count==3 part to recognize the value properly. Even though the count is 3, it doesn't give me a 'success' Thanks.