The UNIX and Linux Forums  

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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
output console problem arghya_owen Shell Programming and Scripting 1 06-17-2008 06:11 AM
Output Problem Eric_Bakken UNIX for Dummies Questions & Answers 3 12-09-2005 02:16 PM
problem with who -u output V.V.KUMAR UNIX for Advanced & Expert Users 0 04-20-2005 10:31 PM
Problem With Who-u Command Output V.V.KUMAR UNIX for Advanced & Expert Users 2 04-11-2005 11:37 PM
somewhat unusual top output problem ohhmyhead UNIX for Dummies Questions & Answers 4 07-17-2004 10:44 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-27-2008
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?
Sponsored Links
  #2 (permalink)  
Old 08-27-2008
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,376
Try...
Code:
grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
... but only if using GNU grep.
  #3 (permalink)  
Old 08-27-2008
Registered User
 

Join Date: Aug 2008
Location: India-Chennai
Posts: 113
Can you provide the file from where you want to fetch the IP?
Google The UNIX and Linux Forums
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:




All times are GMT -4. The time now is 04:33 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66