|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
grep searching
I am making a script but having little problem. at one part I need to find one number format or other format from a file.. those formats are xxx-xx-xxxx or xxxxxxxxx i tried Code:
grep '( [0-9]\{3\}-[0-9]\{2\}-[0-9]\{3\} |[0-9]\{9\})'if i do them sepratly it work but like this it is not working Please check what the problem is with this code Thanks |
| Sponsored Links | |
|
|
|
#2
|
|||
|
|||
|
How about this... Code:
grep -E '[0-9]{3}-[0-9]{2}-[0-9]{3}|[0-9]{9}'-E(or just use egrep) which is for extended regular expression, read the man page for grep |
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
i tried but it's not working. when i use egrep or grep -E it does not return anything. The problem is like this. Code:
some command | some command | some command | grep -E '( [0-9]\{3\}-[0-9]\{2\}-[0-9]\{3\} |[0-9]\{9\})'This does not return anything but if i do separately then both works Code:
some command | some command | some command | grep '( [0-9]\{3\}-[0-9]\{2\}-[0-9]\{3\} 'Code:
some command | some command | some command | grep [0-9]\{9\})' |
|
#4
|
|||
|
|||
|
Your system's grep doesn't support -E, please replace by egrep. Code:
some command | some command | some command | egrep '( [0-9]\{3\}-[0-9]\{2\}-[0-9]\{3\} |[0-9]\{9\})' |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
it is not working either. can you check if the grouping is right or not. or is there any other comand which i can use to take out 2 particular format of number from a file
|
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Do you try malcomex999's command? (They are different with yours.) Code:
grep -E '[0-9]{3}-[0-9]{2}-[0-9]{3}|[0-9]{9}'
egrep '[0-9]{3}-[0-9]{2}-[0-9]{3}|[0-9]{9}' |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Thank you for figuring that out...the problem was, I was using same [0-9]\{3\} but the way he use [0-9] {3} works fine.. thanks
Last edited by Learnerabc; 03-15-2010 at 12:12 AM.. Reason: misprint |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| searching fileextentions (suffix) with grep and/or test | arjanengbers | Shell Programming and Scripting | 4 | 03-04-2010 04:56 AM |
| searching regular expressions with special characters like dot using grep | jpriyank | Shell Programming and Scripting | 4 | 08-12-2009 03:04 AM |
| searching using grep command | prakash.gr | Shell Programming and Scripting | 9 | 12-15-2008 03:30 AM |
| GREP Searching for a newbie... | steveglevin | Shell Programming and Scripting | 8 | 08-27-2007 03:10 AM |
| grep - searching for a specific string | manthasirisha | Shell Programming and Scripting | 2 | 01-05-2006 08:24 AM |
|
|