Search for files in a directory hierarchy.
How:
cd ~find
find . -name '*.bak'
./dir_1/d.bak ./a.bak ./b.bak
find ~/usr -type d
. ./dir_1 ./dir_2 ./dir_2/dir_2.1
find . -ctime -1 -name '*.bak' -exec cp {} /tmp ;
The brace-pair "{}" represents the file(s) found. In fact, the command "cp {} /tmp" will be executed for each file found. If there are 3 files found: a.bak, b.bak, and c.bak, three commands are executed:
Real-life example:
Some quality applications/programs do not clean the temporary files created after use. One of the admin task is to remove them. Here we remove files in /tmp which have not been modified for more than 7 days.
find /tmp -depth -mtime +7 -exec /bin/rm -rf {} ;
There are many options available for find. Its a very powerful tool in system administration. For detail, see its manpage.