"Why don't my regular expressions work with the 'find' utility in Linux/Ubuntu/Unix/Cygwin/Posix-environment?"

Short answer: You need -regextype posix-extended

E.g. To find files with either of two file extensions, use: find . -regextype posix-extended -regex '.*\.(xsd|java)'

Want to know the differences between POSIX Extended Regular Expressions and basic ones? Read this excellent resource about regular expressions. Want to test your regular expressions, live, in the browser? Try Regexpal.

Similarly, use egrep instead of grep to enable extended regex functionality and use sed -r instead of sed.

Published 06/04/2009 Updated 25/05/2010 Tags Systems
comments powered by Disqus