find (find files)
Searches specified directories for files or groups of files.
Format: find directories conditions
Examples: find /home/janet -name "file*.txt" -print
find . -type d -print
The first example searches the directory /home/janet, and all its subdirectories, for any files that begin with file and end with .txt. The filenames are displayed. The second example searches the current directory, and its subdirectories, for directories and displays their names.
Rather than options, find uses conditions that are listed after the argument (the path to search). Some conditions are:
Condition | What It Does | Example |
---|---|---|
-amin +n|-n|n | Find files with last access date more than, less than, or n minutes ago | find . -amin +30 |
-anewer filen | Find files accessed ... |
Get Spring Into Linux® 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.