OSXFAQ Mac OS X UNIX Tip-of-the-Day

Week 102 - Unix Commands Reference II (21 March 2005)
by
Adrian Mayo - Editor, OSXFAQ
Monday - Commands to Search for Files
Last week and the next three weeks will form a Unix command reference by listing lots of commands under specific areas of usage. There are so many commands available that it is impossible to know them all, or even remember all those one knew and used just last month.
See the rest of the tips for lots of example usage of these commands.
See the Learning Centre for tutorials on these commands, and explanations of Unix permissions.
And of course, don't forget the Unix manual 'man'.
To search for files in the files system, use:
find ... find files matching a number of criteria
Option -E to specify extended regular expressions
Option -L to follow symbolic links for found files
Option -X when find is used with xargs
Option -s to search hierarchies in lexicographical order
Check out the many primaries, which specify which files are matched based on many, many criteria such as name, time/date, owners, size, type, permissions, etc
(See tips weeks 1, 13, 31, 49, 97, 98)
locate ... search a database of files
This relies on the locate database being up to date
(See tips week 1)
locate.updatedb ... update the locate database in
(See tips week 1)
The best way to update the locate database database to avoid revealing private filenames is by the command:
$ sudo periodic weekly
(See tips weeks 64, 88)
type ... find an executable (bash shell only)
Option -a to find all versions of the executable
(See tips week 77 - Tuesday)
which ... find an executable (csh and tcsh)
(See tips weeks 20 and 47 - Monday)
whereis ... find an executable (search system path)
Also:
ls -r * ... recursive directory listing
echo * ... list all files in the current directory
If you want to learn more about Mac OS X Unix visit the Learning Center
click.
- For beginners: Mac OS X Unix Tutorials
- For detailed information on specific topics: Advanced Unix
- For OS X in gereral: Mac OS X Tutorials
|