Linux Find, Atime, Ctime,mtime

Source: Internet
Author: User
Tags uppercase letter

Linux CTime refers to change time, atime refers to accesstime,mtime refers to modify time (meaning change)


Mtime and CTime The difference is that only modify the contents of the file to update the file's mtime, and rename the file, modify the properties of the file, and so on, will only update CTime.


Example : MV operation of the file,mtime unchanged,ctime Update, edit the contents of the file,mtime and ctime simultaneously modified. The impact of other operations, but I found that the touch operation on the file, will also modify mtime and CTime, so the specific modification of which time, but also depends on the implementation of the different commands themselves;


Atime, This is updated every time you view the contents of a file. such as cat operations, and LS operations are not updated.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/80/61/wKioL1c_L32ibGxlAAOJmmA_ijw157.png "title=" 6.PNG " alt= "Wkiol1c_l32ibgxlaaojmma_ijw157.png"/>

stat can be used to view the properties of the file mtime,ctime,atime , or can be viewed through the LS command, as follows :

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/80/61/wKioL1c_L6WBQBpOAAPC7hZw1vk024.png "title=" 4.PNG " alt= "Wkiol1c_l6wbqbpoaapc7hzw1vk024.png"/>


LS-LC filename List the ctime of a file

ls-lu filename List the atime of a file

ls-l filename List the mtime of a file

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/80/61/wKioL1c_L7zzCrJkAAHibCzSk6E086.png "title=" 5.PNG " alt= "Wkiol1c_l7zzcrjkaahibczsk6e086.png"/>



1, Search by name

In the current directory and subdirectories, look for an uppercase lettertxtFile
$ find. -name ' [a-z]*.txt '-print   

In/ etcAnd its subdirectories, findHostThe file that starts with
$ Find/etc-name ' host* '-print   

In$HOMEDirectory and its subdirectories, find all Files
$ find ~-name ' * '-print

In the current directory and subdirectories, the lookup is not outBegins withtxtFile
$ find. -name "out*"-prune-o-name "*.txt"-print

2, Search by directory

In the current directory exceptAASearch within subdirectoriestxtFile
$ find. -path "./aa"-prune-o-name "*.txt"-print   

In the current directory and in addition toAAAndBBLook for in subdirectories other thantxtFile
$ find. \ (-path "./aa"-o-path "./bb" \)-prune-o-name "*.txt"-print   

In the current directory, no longer subdirectories, findtxtFile
$ find. ! -name "."-type d-prune-o-type f-name "*.txt"-print

3, Search by permissions

  
in the current directory and subdirectories, look for the master with read and write execution, and other files with reading Execute permission
$ find. -perm 755-print

4. Search By Type
in the current directory and subdirectories, locate the symbolic link file
$ find. -type L-print


5. According to the owner and genus Group

  
find files that belong to www 

      $ find/-user www-type f-print
      Find owner Deleted files  
      Find/-nouser-type f-print
      find genus Group mysql File  
      Find/-group mysql-type f-print
      find files deleted by user group &NBSP
      $ find/-nogroup-type f-print


6. Search by Time
find files that have been changed in 2 days
$ find. -mtime-2-type F-print

  
find files that have been changed 2 days ago
$ find. -mtime +2-type F-print 

 
Find files that are accessed in a day
$ find. -atime-1-type F-print 


find files that were accessed a day ago
$ find. -atime +1-type F-print 

 
Find files that are changed in the day
$ find. -ctime-1-type F-print  


find a day ago state changed file
$ find. -ctime +1-type F-print  


find files that have changed status by ten minutes ago
$ find. -cmin +10-type F-print


7, according to the old and new documents
Find a new file than Aa.txt
$ find. -newer "Aa.txt"-type f-print  


look for older files than aa.txt
$ find. ! -newer "Aa.txt"-type f-print 

 
find newer than Aa.txt , older than bb.txt files
$ find. -newer ' Aa.txt '! -newer ' Bb.txt '-type f-print


8. Search by size
Find Files that are over 1M
$ find/-size +1m-type F-print

  
Find Files that are equal to 6 bytes
$ find. -size 6c-print  


Find Files that are less than 32k
$ find. -size-32k-print


9. Execution of orders
Find del.txt and delete, prompt confirmation before deleting
$ find. -name ' Del.txt '-ok rm {} \; 

 
Find aa.txt and back up as Aa.txt.bak
$ find. -name ' Aa.txt '-exec cp {} {}.bak \;



This article from "Wooden Man" blog, declined reprint!

Linux Find, Atime, Ctime,mtime

Related Article

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.