The find Command

The find command is a very powerful, very flexible way to create a list of files that match given criteria. The basic syntax is

find dir options actions

where dir is the name of a directory and options and actions are discussed in this section.

Here is a simple find example:

$ find / -name alpha -print

This example looks for all files named alpha and displays the full pathname to the screen (standard output). It is a useful command to know about when you are sure you have a file named alpha but can't remember what directory it is in or want to know whether it exists in more than one directory. Here is some possible output from that command:

/reports/1998/alpha
/reports/1998/region2/alpha
/tmp/alpha

If you specify the starting ...

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition 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.