find with a regex path
I'm new to bash scripting and regexp, so sorry if this is a simple question.
I'm using bash scripting to find any file that matches a path governed by the following regular expression: "(monthly|nightly).[0-9]+/home/(user1|user2)/.mailbox/" to match files like: monthly.9/home/user1/.mailbox/l23131564 nightly.15/home/user2/.mailbox/cur/6546213 I've tried: Code:
myRegex="(monthly|nightly).[0-9]+/home/(user1|user2)/.mailbox/" what am I missing? |
This works for me:
Code:
myRegex='.*(monthly|nightly).[0-9]+/home/(user1|user2)/.mailbox/.*' Code:
"This is a match on the whole path, not a search." Cheers, Tink |
Have you tried it without using a variable?
|
Quote:
|
I've narrowed it down to the OR that is giving me problems.
I tried creating a simple file structure with some blank files in it, but this doesn't return any matches. Code:
# mkdir ./test Help?! |
Look at my first response ... it's NOT the or, it's the missing ".*" at the beginning/end,
or the fact that you're not searching from the location where your absolute path starts. Looking at your example above, Code:
$ cd tmp/ Cheers, Tink |
wow, I've spent hours on this.
Thanks, Tink!!!!! |
Pleasure ... ;}
Feel free to push the thanks button. :D |
All times are GMT -5. The time now is 06:42 PM. |