I'm trying to match all files which don't end in jpg
/png
/jpeg
/gif
, and which also do not have a filename starting with a .
.
I'm passing this regex into find
like so:
find -E path/to/dir myregex
Here's the regex
^.*\/[^\.].*\.(?!jpeg$)(?!jpg$)(?!gif$)(?!png$)([^jgp]..|j[^p].|g[^i].|p[^n].|jp[^g]|gi[^f]|pn[^g]|jpg.+|png.+|gif.+|jpe[^g]|jpeg.+)[^\.]*$
It does appear to work, but man is it long... One possibility would be to write a function to generate it... but I wish there was an easier way.
I don't think the version of find
that I'm using (OS X Mavericks) supports lookbehind, but even if it did, I'd like to know if there was an alternative.
Here's an interactive version: http://regex101.com/r/xD9qC2/1
Sorry for the self Q&A here. I spent a while thinking about this before posting my question, but just after posting I had some insight.
It's a little long but it's less brute-forced than the one in the question.
Interactive link