validating 10. IP address any way possible

HELP: validating IP addresses any way possible

--------------------------------------------------------------------------------

I am trying to validate input from the user in a script. I thought is was easy to do using regular expressions but I can't figure out how to use REs in a conditional. I have tried using grep from a temp file, sed from a temp file, sed from command line, comparison in an if condition and I cannot figure it out and I don't have much hair left! i am trying to validate input of an IP address.

Thanks for your help

OK I have tried the following expressions that according to the regex tool match IP addresses, but they all seem to flip flop back and forth for valid and not valid IPs and the entire list albeit 2 or 3 are valid. What is the deal. I would gladly do this another way if anyone could steer me in the right direction. Thanks greatly for your help!!
rc=`egrep -c "[0-9][13]\.[0-9][13]\.[0-9][13]\.[0-9][13]"`

rc=`egrep -c \\b\(?:\(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\)\
\.\){3}\(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\)\\b"`

rc=`egrep -c '\\b\(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\)\\.\(2
5[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\)\\.\(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\)\\.\(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\)\\b'

rc=`egrep -c '10.\([781]|70|80\).\(25[0-5]|2[0-4][0-9]|[01]?[0-
9][0-9]?\)\\.\(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\)\\b'

Moderator,

Please close this thread, the same user posted the same question yesterday in shell programming section and I have replied for that... without checking or replying to that he posted again here.... not following the rules by duplicating the messages.

It is waste of time replying to this kind of users anymore...

Thanks..Mahendra.