find—finds files

find path–name–list expression

find recursively descends the directory hierarchy for each pathname in the pathname list (i.e., one or more pathnames) seeking files that match options. The first argument is the path where the search starts. The rest of the arguments specify some criteria by which to find the files, such as name, size, owner, permissions, etc. Check the UNIX manual pages for different syntax.

Example A.27.
1   find . -name \*.c -print
2   find .. -type f
3   find . -type d -print
4   find / -size 0 - exec rm "{}" \;
5   find ~ -perm 644 -print
6   find . -type f -size +500c -atime +21 -ok rm -f "{}" \;
7   find . -name core -print 2> /dev/null (Bash/Korn shells)
					( find . -name core -print > /dev/tty ) >& /dev/null (C/TC ...

Get Linux Shells by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.