Searching for Files
The locate
command searches a database of file names.
The find
command searches your disk for files
matching various critera.
Examples:
locate .mp3
locate "Work Order"
find . -name "*.mp3"
find /Users/puffball/Documents -name "*Work Order*"
Tasks:
- What GUI program is similar to
find
and locate
?
- What can you do with these command
lines tools that you cannot do with the GUI program?
Tips:
- Piping the output of
find
or locate
through the xargs
command allows you to supply every file
name found as an argument to the same command, over and over. See man
xargs
.
- The database for
locate
is updated once a week at
4:30am on Sunday, by the /etc/periodic/weekly/500.weekly
script which is run by the periodic
command which is run
by /etc/crontab
. If your Mac isn't running at 4:30am
Sunday this won't get run.