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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with GREP. syndex Shell Programming and Scripting 2 07-11-2007 01:44 PM
Grep Problem avadhani UNIX for Dummies Questions & Answers 8 06-23-2005 02:58 PM
grep problem svennie UNIX for Dummies Questions & Answers 5 11-08-2004 04:29 AM
Grep Problem lesstjm Shell Programming and Scripting 2 10-27-2004 10:13 AM
Grep problem odogbolu98 Shell Programming and Scripting 3 02-18-2003 03:53 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 06-22-2005
asal_email2 asal_email2 is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 6
grep problem

I know that grep will display the matched line, but how about if I want to get the matched characted, for example:

file.txt contains:
Hello 123 World
This is a56 letter34
56are you su345re ?
1000 yes I do

I want to list all instances of digits that appear e.g:
123
56
34
56
345
1000

do I have to use sed ?

Thanks !
  #2 (permalink)  
Old 06-22-2005
ortsvorsteher ortsvorsteher is offline
Registered User
  
 

Join Date: Aug 2001
Location: germany, bavaria
Posts: 48
Hello,

you can use

grep [0-9] filename

but without sed.... it doesnt work...

regards
  #3 (permalink)  
Old 06-22-2005
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
i believe this wont work

above reply would extract the entire line if matched

and the question was to retrieve only the numeric instances from the file
  #4 (permalink)  
Old 06-22-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
For grep.

Code:
grep -o '[0-9][0-9]*' filename
Vino

Last edited by vino; 06-22-2005 at 04:19 AM..
  #5 (permalink)  
Old 06-22-2005
asal_email2 asal_email2 is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 6
Thanks Vino

Thanks
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 10:15 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