Get the App
SLTechnology News&Howtos  ›  Development  › 

How does linux search based on file time

Shulou Source: shulou.com Published: 2022-06-01 04:59:06 09月28日 Update

This article mainly introduces linux how to search according to the file time, the article is very detailed, has a certain reference value, interested friends must read it!

Search based on file time

Each file in the Linux file system has three timestamps

Access time (- atime): the last time the user accessed the file

Modification time (- mtime): the time when the content of the file was last modified.

Change time (- ctime): the time when the file metadata (metadata, such as permissions or ownership) last changed.

-atime,-mtime,-ctime is used as a time parameter in days. You can use + to indicate greater than, and-to indicate less than.

The code is as follows:

[root@localhost] # find. -type f-atime prints out the file [root@localhost ~] # find that was accessed exactly 7 days ago. -type f-mtime + print files with a modification time of more than 7 days [root@localhost ~] # find. -type f-ctime-prints files with a modification time of less than 7 days

Similar parameters include-amin (access time),-mmin (modification time), and-cmin (change time), in minutes.

Another beautiful feature of find is the-newer parameter. We can specify a parameter file for comparing timestamps, and then find all the files that are newer than the parameter file.

Find. -type f-newer file.txt

P find all files in the current directory that take longer to modify than file.txt.

The above is all the contents of the article "how linux searches based on file time". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Time files parameters search content units articles changes beauty code value interests guys partners ownership data more permissions features users Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Xiaomi NVidia Shulou Tech Info Shulou Technology