find uses emacs regular expressions, which is annoying. I recommend filtering the results with egrep, e.g.:
find|egrep 'regex' find|egrep -i 'regex' # case insensitive find|egrep -v 'regex' # find the files that *don't* match
The find regular expressions are like POSIX 1003.2 regular expressions, except that the { } metacharacters cannot be used, and ( ) | are escaped (and other stuff)
Metacharacters:
. ^ $ \( \) \| ? + * [ ] [^ ]
Extensions:
find has non-greedy versions of ? * +
?? +? *?
find also has case-insensitive search with the -iregex argument
Find all subversion-related files:
$ find -regex ".*\.svn.*"
Find all movie files:
$ find -iregex ".*\.\(mpe?g\|avi\|mov\|qt\|wmv\|asf\)$"
find a file named "huba" in homedir and subdirs
$ find ~ -name huba
find a file named "HUBA" or "huga" or ... in homedir and subdirs
$ find ~ -iname "hu?a"
find all files changed in the last 10 minutes
$ find / -cmin -10
find all directories
$ find -type d
find all regular files
$ find -type f
find all dot-files (not directories) in homedir only
$ find ~ -name ".*" -maxdepth 1 -type f (implicit '-and' between expressions...)
find and pretty-print all files modified today or owned by myself and modified a week ago
$ find / -mtime -1 -or \( -user schmid -mtime 7 \) -printf "%7AA d. %Ad. %Ab kl. %AX ændrede jeg filen '%f'.\n"
find all files called "*CVS/Root" and change "3.80" to "3.80:" in them - note: Don't try this at home!
$ for x in `find -regex ".*CVS/Root"`;do sed -e "s/3\.80/3\.80:/" $x >$x.sed;mv $x.sed $x; done