|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
regex for ls command
Forgive me if this has been posted, but I could not find them. I have thousands of files from a permutation as: Code:
intersect-1234.tab intersect-9914.tab intersect-0123456.tab intersect-9134512.tab ...... Basically there are two groups, one is the Code:
intersect-[0-9][0-9][0-9][0-9].tab and the other is Code:
intersect-[0-9][0-9][0-9][0-9][0-9][0-9].tab When I tried command: Code:
ls intersect-[0-9]\{4\}.tabor Code:
ls intersect-[0-9]\{6\}.tabneither worked but with error message: Code:
ls: cannot access intersect-[0-9]{6}.tab: No such file or directoryIt seems my regex is fine as when I used pipeline: Code:
ls *.tab | grep intersect-[0-9]\{6\}.tabI must have missed something with the regex for ls? Anyone please give me clue? Thanks for help! |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
You have missed something indeed: shell regexps (aka "globs") and regexps are NOT the same.
See the man page of your shell for a detailed list of file globs, but if they aren't sufficient for your purpose you will have to do like you dike already: "ls | grep <some_regexp>" or something similar (awk, sed, ... all use the same regexps). I hope this helps. bakunin |
| The Following User Says Thank You to bakunin For This Useful Post: | ||
yifangt (07-13-2012) | ||
| Sponsored Links | ||
|
![]() |
| Tags |
| ls, regex, repetitive occurence, shell commands |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| command to check existence of file name which has regex | skpvalvekar | Shell Programming and Scripting | 2 | 06-24-2011 06:59 AM |
| Using regex in find command | Zucriy Amsuna | UNIX for Dummies Questions & Answers | 27 | 04-22-2011 10:29 PM |
| Regex in find command | siba.s.nayak | UNIX for Dummies Questions & Answers | 3 | 11-23-2010 01:33 PM |
| combining perl regex'es into a single command | hcclnoodles | Shell Programming and Scripting | 4 | 09-23-2009 10:43 AM |
| testing for regex at command line | ankimo | UNIX for Dummies Questions & Answers | 4 | 10-08-2008 02:18 PM |
|
|