Today, we will use some search commands in windows to help you find what you want. In linux and I have been writing centos, the search command is equally powerful. The commonly used whichwhereislocatefind4 methods focus on finding. it is best to use other commands in combination.
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-y mlocate
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.