Like this CertiGuide? Get it in PDF format!
Click Here!

Custom Search







Table Of Contents  CertiGuide to A+ (A+ 4 Real)
 9  Chapter 5: The Linux Operating System
      9  Basic Concepts and Procedures for Creating, Viewing and Editing Files and Directories
           9  Common Commands

Previous Topic/Section
chmod - Change File Access Permissions
Previous Page
Pages in Current Topic/Section
1
Next Page
locate - Index And Search Files
Next Topic/Section

find - Search For Files In A Directory Hierarchy

The find command has an incredibly wide range of options that allow one to search through the file system for files with many search options. For example, one could look for a file that started with the characters stran, was modified two days ago, is 1000 bytes long, and owned by the user, newuser. Only a few options will be covered here, the man pages and info pages give much more detail about this powerful command. Table 7 shows a short list of some of the possible options that can be used with this command.

First let’s look at the general form and common options (shown in Table 14).

find [path ] [expression ...]


Table 14: find Command Options

Option

Description

-atime n

File was last accessed nx24 hours ago.

-mtime n

File’s data was last modified nx24 hours ago.

-name pattern

Base of file name matches shell pattern: pattern.

-size n

Finds files of n blocks (block size is 512 bytes)

-user user

Finds files owned by user


An example or two will help:

find . -name „hat[23]*’

This will search in the current directory (remember . refers to the current directory) and in sub directories for any files that start with the characters, hat, followed by the number 2 or 3 and having zero or more additional characters.

find / -user new_user

This will start a search at the root directory and search through all of the system’s directories and sub directories for any file owned by the user new_user and list all those files.

find /var -mtime -1

This will search in the directory /var looking for files that were modified within the last 24 hours.

Note: searching in directories for which one does not have permission to read will report an error appear for those directories stating that there were insufficient permissions to search that directory.

Find will keep executing, looking through every directory within the path given.

If find is given, a search list of a large number of directories or files it can take a long time to execute, as in the second example, starting at the root directory, can take several seconds. Be patient.


Previous Topic/Section
chmod - Change File Access Permissions
Previous Page
Pages in Current Topic/Section
1
Next Page
locate - Index And Search Files
Next Topic/Section

If you find CertiGuide.com useful, please consider making a small Paypal donation to help the site, using one of the buttons below. You can also donate a custom amount using the far right button (not less than $1 please, or PayPal gets most/all of your money!) In lieu of a larger donation, you may wish to consider buying an inexpensive PDF equivalent of the CertiGuide to A+ (A+ 4 Real) from StudyExam4Less.com. Thanks for your support!
Donate $2
Donate $5
Donate $10
Donate $20
Donate $30
Donate: $



Home - Table Of Contents - Contact Us

CertiGuide to A+ (A+ 4 Real) (http://www.CertiGuide.com/apfr/) on CertiGuide.com
Version 1.0 - Version Date: March 29, 2005

Adapted with permission from a work created by Tcat Houser et al.
CertiGuide.com Version Copyright 2005 Charles M. Kozierok. All Rights Reserved.
Not responsible for any loss resulting from the use of this site.