Help with grep

I have a text file (num.txt) with contents like:
457878600
575909798
767909780
.
.

and another file (data.txt) has data related to some of the above numbers.
I need to grep each number from num.txt on data.txt file to check if the data related to that number exist in the file or not
if exists continue with next nbr
if does not exist need to run a command
can any one suggestme how the above verification can be done using if else?
:wall:

#! /bin/bash
while read num
do
    grep -q $num data.txt
    if [ $? -ne 0 ]
    then
        <run_command>
    fi
done < num.txt

Try this, I hope this will help u.

while read line
do
    grep "$line" data.txt > /dev/null
    if [ $? -eq 0 ]
    then
        echo "$line number present in data file"
    else
        echo "$line number not present in data file"
        <<< execute the command u need >>>
    fi
done<num.txt

Generic way ..

while read A
do
        grep $A data.txt > /dev/null
        [ $? -ne 0 ] && echo "Run a command"
done < num.txt

no need for the loop:

grep -f num.txt data.txt

should do the trick

EDIT: Sorry, I misread the OP's requirements. Never mind this post.

for i in `cat num.txt`
do
search=`grep "$i" data.txt`
ret_cd=$?
if [ "$ret_cd" -gt 0 ]
then
echo "Match not found ,run a command"
fi
done

try this...

grep -vf num.txt data.txt | xargs -i echo "no match {}"

note: you can replace echo with command you want to execute.