DistributedNetworks DistributedNetworks

File Management  «Prev 

Using the find command in Unix

find is a command-line utility that searches through one or more directory trees of a file system, locates files based on some user-specified criteria and applies a user-specified action on each matched file.
The possible search criteria include a pattern to match against the file name or a time range to match against the modification time or access time of the file. By default, find returns a list of all files below the current working directory. The related locate programs use a database of indexed files obtained through find to provide a faster method of searching the entire filesystem for files by name.

In the simplest case, with no conditions specified, the find command searches the specified pathname or pathnames and displays everything inside

In this example, the -type d (for directory) condition modifies the search by displaying the images directory and any of its subdirectories.

In this example, the condition-type f (for file) causes only the regular files to be listed.

Unix OS Concepts
The -name condition lets you specify a file name to look for. You must enclose the pattern in quotes if you use wildcards.

As with any command that displays results on your screen, you can use output redirection to save the result of the find command

The pathname argument you supply can be absolute or relative. You can supply multiple pathnames, as well as the current directory (.), as shown in this example