Reference: find
find
find pathname(s)
condition(s)-atime+n |-n | n-cpiodev-ctime+n |-n | n-depth-execcommand{} \;-
Run the Unix command on each file matched by find, provided command executes successfully on that file; i.e., returns a 0 exit status. When command runs, the argument
{}substitutes the current file. Follow the entire sequence with an escaped semicolon (\;). -follow-
Follow symbolic links and track the directories visited (don't use this with
-type l). -fstypetype-groupgname-inumn-
-linksn-local-
Find files that physically reside on the local system.
-ls-
Display matching files with associated statistics (as if run through
ls -lids). -mount-mtime+n |-n | n-namepattern-
-ncpiodev-newerfile-
Find files that have been modified more recently than file; similar to
-mtime. -nogroup-
Find files belonging to a group not in /etc/group.
-nouser-okcommand{} \;-permnnn-
-print-
Print the matching files and directories, using their full pathnames. On Solaris, this is the default.
-prune-
"Prune" the directory tree of unwanted directory searches; that is, skip the directory most recently matched.
-sizen[c]-typec-
bBlock special file cCharacter special file dDirectory DDoor special file, Solaris only fPlain file lSymbolic link pFifo or named pipe sSocket -useruser-
-xdev
Examples
List all files (and subdirectories) in your home directory:
find $HOME -print
List all files named chapter1 underneath the /work directory:
find /work -name chapter1 -print
find /work /usr -name 'memo*' -user ann -print
find / -type d -name 'man*' -print
find . \! -name '[A-Z]*' -exec lp {} \;
compress `find . -type f \! -name '*.Z' -print`
Remove all empty files on the system (prompting first):
find / -size 0 -ok rm {} \;
Skip RCS directories, but list remaining read-only files:
find . -name RCS -prune -o -perm 444 -print
find / -mtime -2 -print
find /book -print | xargs grep '[Nn]utshell'

