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



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 03: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
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #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?
  #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,407
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
palsevlohit_123 palsevlohit_123 is offline
Registered User
  
 

Join Date: Aug 2008
Location: India-Chennai
Posts: 120
Can you provide the file from where you want to fetch the IP?
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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