Unix/Linux Go Back    


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 !!

Grep a line with between 3 and 5 digits

UNIX for Dummies Questions & Answers


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 09-17-2007
ceemh3 ceemh3 is offline
Registered User
 
Join Date: Sep 2007
Last Activity: 18 September 2007, 10:53 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Grep a line with between 3 and 5 digits

Hi,

I am having problems using grep to extract only 3,4 or 5 digit numbers from a text file, using:

grep '\<[0-9]\{3,5\}\>' test.txt
or
grep '[0-9]\{3,5\}' test.txt
or
egrep '[0-9]{3,5}' test.txt

I would appreciate any help that anyone can give me

thanks

Last edited by ceemh3; 09-17-2007 at 10:58 AM..
Sponsored Links
    #2  
Old Unix and Linux 09-17-2007
robotronic's Unix or Linux Image
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
 
Join Date: Apr 2002
Last Activity: 20 December 2009, 10:56 AM EST
Location: Italy
Posts: 370
Thanks: 0
Thanked 0 Times in 0 Posts
On Linux, this command works correctly:


Code:
grep '\<[0-9]\{3,5\}\>' test.txt

On Solaris you may try this (not tested though):


Code:
/usr/xpg4/bin/grep -E '\<[0-9]\{3,5\}\>' test.txt

Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Listing all digits behind the comma with grep intelinside Shell Programming and Scripting 2 04-22-2012 02:21 PM
how to use grep: finding a string with double quotes and multiple digits titusbass UNIX for Dummies Questions & Answers 3 01-17-2011 06:39 PM
matching 3 digits at the begining and the end of the line bartsimpsong UNIX Desktop for Dummies Questions & Answers 2 10-19-2010 08:18 AM
locate special characters and digits using grep hobiwhenuknowme UNIX for Dummies Questions & Answers 2 08-10-2010 08:08 PM



All times are GMT -4. The time now is 01:05 PM.