Linux Common commands-File Search command find

Source: Internet
Author: User

File Search command Find

Command name: Find

Command path:/bin/find

Execute Permissions: All Users

Syntax: Find [Search Range] [match condition]

Function Description: File search

-name Search by file name: find/etc/-name init fuzzy search uses wildcard characters * Find/etc-name *init* matches a single character using a wildcard? Find/etc-name init??

-iname Search by file name (case insensitive)

-size in the directory according to the file size look for example: Find/-size +204800 (+; n is less than; n equals the search size in chunks, 1 blocks = 512 bytes =0.5k;100mb=1024000kb= 204800 data blocks)

-user in the directory under the owner-condition Lookup Example: Find/home-user xiaoming

-group based on the owning group

-amin Access by file for a period of time (access) Find an example: find/etc-amin-5 (+: how long;-: how long)

-cmin Modify file attribute (change) Lookup example based on file for a period of time: find/etc-cmin-5

-mmin Modify the file contents (modify) for a period of time based on the file look for an example: find/etc-mmin-5

-type Search by file type (f: File D: directory; L: Soft link file)

-inum based on I-node lookup

Connection query for search criteria

-a two conditions at the same time satisfied example: Find/etc-size +163840-a-size-204800

-O two conditions to satisfy any one example: Find/etc-size +163840-o-size-204800

-exec/-ok command {} \; To perform an operation on a search result: Find/etc-name init-exec ls-l {} \; Find/etc-name init-ok ls-l {} \; (The action that will be queried for each qualifying result, such as deleting a search file Find/etc-name init*-ok rm {} \; asks if each file is deleted )

Other Search commands

Command name: Locate (-I case insensitive)

Command path:/usr/bin/locate

Execute Permissions: All Users

Syntax: Locate file name

Function Description: Find files in the file repository (file repository/var/lib/mlocate/mlocate.db,linux will periodically synchronize the file information to this file, the execution of the updatedb command will immediately update the file repository,/ TMP directory is not in the file repository) Example: Locate Inittab;

Command name: which

Command path:/usr/bin/which

Execute Permissions: All Users

Syntax: which command

Function Description: Search command directory and alias Information example: which LS

Command name: Whereis

Command path:/usr/bin/whereis

Execute Permissions: All Users

Syntax: Whereis [command name]

Function Description: Search command directory and Help document path example: Whereis ls

Command name: grep

Command path:/bin/grep

Execute Permissions: All Users

Syntax: Grep-iv [Specify string] [file]

Function Description: Search for string matching lines in the file and output-I case-insensitive-V-Exclude specified string example: grep mysql/root/install.log

Linux Common commands-File Search command find

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.