4.5. Finding Files: findThe find utility can do much more than simply locate a named file; it can perform actions on a set of files that satisfy specific conditions. For example, you can use find to erase all of the files belonging to a user tim that haven't been modified for 3 days. Figure 4-11 gives a formal description.
Figure 4-12 is a table that describes the syntax of expression.
Here are some examples of find in action: $ find . -name '*.c' -print ...print c source files in the ...current directory or any of ...its subdirectories. ./proj/fall.89/play.c ./proj/fall.89/referee.c ./proj/fall.89/player.c ./rock/guess.c ./rock/play.c ./rock/player.c ./rock/referee.c $ find . -mtime 14 -ls ...ls modified files ...during the last 14 days. 286580 16 -rw-r--r-- 1 glass cs 14151 May 1 16:58 ./stty.txt 286377 4 -rw-r--r-- 1 glass cs 48 May 1 14:02 ./file.doc 284428 4 -rw-r--r-- 1 glass cs 10 May 1 14:02 ./rain.doc 287331 16 -rw-r--r-- 1 glass cs 14855 May 1 16:58 ./tset.txt 288646 48 -rw-r--r-- 1 glass cs 47794 May 2 10:56 ./mail.txt $ find . -name '*.bak' -ls -exec rm {} \; ...ls and then remove all files ...that end with ".bak". |