Linux Find command find with file three kinds of time

Source: Internet
Author: User

The Find command in Linux is as follows:

Which view the location of the executable file.

Whereis View the location of the file.

Locate to view the file location with the database.

Find actual search hard disk query file name.

Where find is a powerful feature, find is used as follows:

Find command format

Find Pathname-options [-print-exec-ok ...]

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s4.51cto.com/wyfs02/m00/80/6d/wkiol1dbzdwsf0heaaciggymgcw366.jpg "title=" Wkiom1dbvxrg-xsraacisbzttp0572.jpg " alt= "Wkiol1dbzdwsf0heaaciggymgcw366.jpg"/>

Command parameters:

The directory path that the Pathname:find command looks for. For example, use. To represent the current directory, and/to represent the system root directory.

The-print:find command outputs the matched file to standard output.

The-exec:find command executes the shell command given by the parameter to the matching file. The corresponding command is in the form of ' command ' {} \;, note the spaces between {} and \.

-ok: The same as-exec, except that the shell command given by the parameter is executed in a more secure mode, prompting the user to determine whether to execute before executing each command.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s2.51cto.com/wyfs02/m00/80/6f/wkiom1dbzalgmj0paaburindgbw867.jpg "title=" Wkiol1dbwe3gce_kaabutcogdnc454.jpg " alt= "Wkiom1dbzalgmj0paaburindgbw867.jpg"/>

Command options:

-name finds files by file name.

-perm to find files according to file permissions.

-prune Use this option to have the Find command not be found in the currently specified directory, and if you use the-depth option at the same time,-prune will be ignored by the Find command.

-user Search for files according to the owner of the file.

-group finds files according to the group to which the files belong.

-mtime-n +n The file changes time to find the file,-n means that the file change time is now less than n days, + n means that the file change time is now N days ago. The Find command also has the-atime and-ctime options, but they are all the same as the-m time option.

-nogroup finds a file that does not have a valid owning group, that is, the group to which the file belongs does not exist in/etc/groups.

-nouser finds a file without a valid owner, that is, the owner of the file does not exist in the/etc/passwd.

-newer file1! File2 look for a file that changes time than the file File1 new but older than the file file2.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s4.51cto.com/wyfs02/m01/80/6d/wkiol1dbzsltmlrlaahdwpb0pgi408.jpg "title=" Wkiom1dbwnqcmnsdaahdm8isf4c677.jpg " alt= "Wkiol1dbzsltmlrlaahdwpb0pgi408.jpg"/>

-type find a file of a certain type, such as:

B-block device files.

D-Directory.

C-character device file.

P-Pipeline file.

L-Symbolic link file.

F-Normal file.

-size N:[c] finds files with a file length of n blocks, with C indicating the length of the file in bytes.

-depth: When looking for a file, first find the file in the current directory, and then look in its subdirectories.

-fstype: Find files located in a file system of a certain type, these file system types can usually be found in the configuration/etc/fstab, which contains information about the file system in this system.

-mount: Does not cross the file system mount point when locating files.

-follow: If the find command encounters a symbolic link file, it tracks to the file that the link points to.

-cpio: Use the cpio command for matching files to back up these files to the tape device.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s1.51cto.com/wyfs02/m02/80/6d/wkiol1dbzuqam9r5aagglv6_6ig609.jpg "title=" Wkiom1dbwcohyip2aaggm-gqbny194.jpg " alt= "Wkiol1dbzuqam9r5aagglv6_6ig609.jpg"/>

Lookup with Conditional restrictions:

-A with conditions

-O or condition

-not Non-conditional (this parameter functions like a negative argument '! ') )

Find. -name "*.txt", files ending with. txt

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s1.51cto.com/wyfs02/m02/80/6f/wkiom1dbzifxtczmaacikbfszdi266.jpg "title=" Wkiom1dbvjkabnxbaacikngu0pc501.jpg " alt= "Wkiom1dbzifxtczmaacikbfszdi266.jpg"/>

Sets the depth parameter that the Find command traverses in subdirectories:

-maxdepth

-mindepth

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s5.51cto.com/wyfs02/m01/80/6f/wkiom1dbzliadkdmaacblqvj99g182.jpg "title=" Wkiol1dbvqvj30qsaacbbbwgowe658.jpg " alt= "Wkiom1dbzliadkdmaacblqvj99g182.jpg"/>

Find by file time

Linux files are divided into state change time CTime, modified time mtime and access time Atime

(1) Modify the state change time CTime situation is as follows:

A. Modify file permissions or attributes such as owner, number of links, etc. chmod,chown,ln and other operations (not including ln -s ).

B. Modify the contents of the file. (It will also change the mtime, if the use of tools such as vim to open the file and then modify, but also modify the atime.) If you use echo ‘hehe‘ >> test This command only for Append writes, only the Ctime,mtime will be modified, without affecting atime.

(2) modification refers to the modification of the operation, not to say that the contents of the file unchanged it will not change, but the need for the file has not been written operation;

(3) As long as we are reading the file, will modify the access time atime.


find -type f -atime -1   #查找1天内被访问的文件

find -type f -atime  1   #查找恰好在1天前被访问的文件

find -type f -atime +1   #查找超过1天没被访问的文件

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s5.51cto.com/wyfs02/m01/80/6f/wkiom1dbzowxysplaacogflpsai671.jpg "title=" Wkiol1dbvl_scxt_aacorqh4yc0500.jpg " alt= "Wkiom1dbzowxysplaacogflpsai671.jpg"/>

Find by file time

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m00/80/6d/wkiol1dbzfhc9vwnaab2lrkxyns465.jpg "title=" Wkiol1dbvd6ajzjpaab2qo-irzy300.jpg " alt= "Wkiol1dbzfhc9vwnaab2lrkxyns465.jpg"/>


This article is from the "Learning Records" blog, so be sure to keep this source http://10794428.blog.51cto.com/10784428/1775881

Linux Find command find with file three kinds of time

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.