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 -->
  #1 (permalink)  
Old 08-27-2008
snake450 snake450 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 5
Problem in output

When i use the following command to get only the ip address from a file then i get a whole sentence and not only the ip address which i want.

here is the script i am using:

grep '^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$'

for example if this the file content:

Many blogs provide commentary or news on a particular subject; others function as more personal . A typical blog combines text, images, and links to other blogs, and other media related to its topic. The ability for readers to leave comments in an interactive format with ip address 129.23.45.78

then the output looks like this :

leave comments in an interactive format with ip address 129.23.45.78

but the desired output should be like this:

129.23.45.78

what should i do to fix the problem?