The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 08-26-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,421
Quote:
Originally Posted by snake450 View Post
Please correct me if i am wrong.

grep '^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$' followed by
Your regexp will match anything upto 999.999.999.999

For IPv4 try this awk solution:
Code:
awk -F'.' 'NF==4 && $1 > 0 && $1 && $2 && $3 && $4 <256'
If IP match use the system function to dig your ip and printf to format the output.

Regards,