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:
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.
check="Mike Joe Blair"
for namex in $check
if grep $namex datatest > /dev/null; then
count='expr $count + 1
echo "$namex found"
if [ $count==3 ]; then
echo "Did not find all matches"
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.