Need help with regular expression
I am trying to use find (under linux) to match file names of the form <anything>_[0-9]. For example:
text_0.txt .foo_19.bar.c etc. I am using: find . -regex '^\.*_[0-9]+' -print So far it will only match the filename if it is preceeded by a "." What am I doing wrong? |
the backslash is making the dot go literal. This should work :
Code:
find . -regex '_[0-9]+\.' -print |
Nope, doesn't work.
Actually the "\" in my first post wasn't necessary. Even without it, the regex only finds filenames with an initial "." It's as if the dot is being escaped even without the slash. |
my aix version of 'find' doesn't like regex.
Code:
schneidz@lq:/temp> find . -regex '_[0-9]+\.' -print Code:
schneidz@lq:/temp> find . | grep _[0-9] |
Thanks, schneidz, that does it!
Although, for my own information, It would be instructive if someone could tell me why the -regex as above doesn't work. |
have you heard of man ?
;) Code:
|
Yes, I also noticed that the whole path is matched. Not only that, find adds a carot at the start and a dollar sign at the end of the expression. So the following regexp SHOULD work :
Code:
find . -regex '.*_[0-9]+\.[^/]*' |
All times are GMT -5. The time now is 07:37 PM. |