Operating System - HP-UX
1834385 Members
2015 Online
110066 Solutions
New Discussion

finding regular expression repeated occurances

 
SOLVED
Go to solution
Lonny Balderston
Frequent Advisor

finding regular expression repeated occurances

I am trying to list files whose names contain 8 consecutive digits. According to "man 5 regexp", command "ls *[0-9]\{8\}*" should work, but it does not. What is the proper syntax for finding regular expression repeated occurances? Thank you.
2 REPLIES 2
Rodney Hills
Honored Contributor
Solution

Re: finding regular expression repeated occurances

Filename wildcards aren't the same as regular expressions.

For example a "." is any character in regexp, while "?" is any character in wildcards.

To list files with 8 digits-
ls *[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]*

HTH

-- Rod Hills
There be dragons...
A. Clay Stephenson
Acclaimed Contributor

Re: finding regular expression repeated occurances

Because the shell does not fully implement regular expressions
to use your example
ls *[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]* would have worked.

Commands like grep -E, sed, and awk fully implement regular expressions and Perl extends RE's to almost ludicrous (albeit useful) levels.
If it ain't broke, I can fix that.