Get the App
SLTechnology News&Howtos  ›  Servers  › 

Example Analysis of search Command in CentOS

Shulou Source: shulou.com Published: 2022-06-01 18:40:47 10月03日 Update

This article will explain in detail the sample analysis of search commands in CentOS. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

We all use some search commands to help ourselves find what we want when we can't find a file under windows.

Search commands under linux and the centos that I have been writing are equally powerful.

The commonly used ones are which whereis locate find.

The focus of the four methods is on find, and other commands are best used together.

Which

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

Generally use which limited scope of use / PATH, executable binary commands are his search scope.

Whereis

Belongs to imprecise search, with search commands but limited scope, generally at / bin, / usr/share

Locate

This command cannot be used directly. Dependent packages need to be installed.

Yum install-y mlocate

And

Remember that updatedb synchronizes the database files on which this command depends before using it, otherwise there will be no results.

Find

Finally getting to the point.

Find scope-type f searches for ordinary files within the specified scope type represents the file type

Find scope-type d searches for directory files within the specified scope type represents the file type

Look at the example

You can search precisely to specify the file name you are looking for

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

Look at the example

The second command "1 *" * wildcard meaning

You can also search for matches based on the three time on the linux file.

Three time

Atime access time access time

Ctime is a time that changes the inode information of a file, or a time that changes the properties of a file.

Mtime is the time that changes the contents of a file

Eg

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

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

If you are searching for an hour, use mmin.

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

You can also use pipe characters | use it in conjunction with xargs.

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

To view the three time, you can use stat to better understand the three time. Take a look at the following figure 1, the changes of the three time.

Echo affects mtime and ctime

Touch affects three time

This is the end of this article on "sample analysis of search commands in CentOS". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: File search command scope three articles search examples life claims analysis precision representation content examples more types help influence good practical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Apple Xiaomi Shulou Information vpn