CentOS SEARCH Command

Source: Internet
Author: User

CentOS SEARCH Command

Introduction to search commands today

Files cannot be found in windows. We will use some search commands to help ourselves find what we want.

In linux and I have been writing centos, THE SEARCH Command is equally powerful.

Commonly used which whereis locate find

The focus of the four methods is on finding. Other commands are best used together.

Which

In fact, this is also used in the previous post, generally for executable commands, which is more.

Generally, when which is used in a limited range/PATH, the executable binary command is his search range.

Whereis

It is an inaccurate search and has search commands, but the range is also limited. It is usually in/bin,/usr/share

Locate

This command cannot be used directly. You need to install the dependent package.

Yum install-ymlocate

And

Before using updatedb, remember to synchronize the database files that the command depends on. Otherwise, no results will be returned.

Find

The key point finally begins.

Find range-type f search common file type in a specified range represents the file type

Find range-type d search the directory file type in the specified range represents the file type

View instances

You can precisely search for the specified file name.

Find/tmp-name "123" or find/tmp-name "1 *"

View instances

The second command "1 *" * wildcard meaning

You can also perform matching searches based on the three times in the linux File.

Three times

Atime access time

Ctime is the time used to change the inode information of a file, or the time used to change the file attributes.

Mtime is the time for changing the File Content

Eg

Find/root-name "* txt"-mtime + 5 search for files created five days ago

Find/root-name "* txt"-mtime-5 search for files created within 5 days

If you search for mmin for an hour

Find/root-name "* txt"-mtime-60

You can also use the pipeline operator | used with xargs for this purpose

Find/tmp-name "1 *"-mtime-1 | xargs ls-l

You can use stat to view the three time ranges. for better understanding of the three time ranges, see 1----2----3.

Echo affects mtime and ctime

Touch affects three times.

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.