I have a regular expression that seams to work in Javascript, but doesn't work with the Linux find command. The purpose is to gather a list of files that have been updated in the last 90 days, excluding particular directories (for example, assume I want to include the directory /data/safe/23/test, but not /data/safe/23/skip1). Here is the regex:
^/data/safe/\d{1,4}/(?:(?!skip1|skip2).*)
And here is the find command (notice I'm using posix-extended; that may be the problem):
find /data/safe -regextype posix-extended -regex '^/data/safe/\d{1,4}/(?:(?!skip1|skip2).*)' -mtime -90
And finally this is the error that is generated:
find: Invalid preceding regular expression
Any help is greatly appreciated!
I think that posix-extended does not supports "?:" and "?!".
Anyway, with find, it would be easier to use something like:
find /data/safe -regextype posix-extended -regex '^/data/safe/[0-9]{1,4}/.*' ! -regex '^/data/safe/[0-9]{1,4}/(skip1|skip2).*' -mtime -90
You're doing it wrong. You need to replace the curly brackets with asterisks. Also you should be piping that whole thing through the tar or touch commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With