Get the App
SLTechnology News&Howtos  ›  Development  › 

How to quickly find the recently modified file in Linux

Shulou Source: shulou.com Published: 2022-06-01 20:08:09 09月21日 Update

This article will explain in detail how to quickly find the recently modified files in Linux. 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.

1. Use the ls command to list only today's files # ls-al-- time-style=+%D in your home folder | grep 'date +% D'

Where:-a-lists all files, including hidden files-l-enable long list format >-time-style=FORMAT- displays the time of the specified FORMAT +% D-displays or uses the date in >% m/%d/%y (month / day / year) format

Quickly find the recently modified file! Quickly find the recently modified file!

Find the most recent file in Linux

In addition, you use the can-X flag to sort the results alphabetically:

# ls-alX-- time-style=+%D | grep 'date +% D'

You can also use the-S flag to sort based on size (from large to small):

# ls-alS-- time-style=+%D | grep 'date +% directory 2. In addition, using the find command is more flexible and provides more options than ls to achieve the same purpose-the maxdepth level is used to specify the search level (subdirectory level) at the starting point of the search operation (in this case, the current directory). NewerXY is used for files whose timestamp X is newer than the timestamp Y of the reference file. X and Y denote any of the following letters:-a-access time of the reference file-B-creation time of the reference file-c-inode state change time of the reference file-m-modification time of the reference file-t-specify an absolute time directly

The following command means to find only the files modified on 2016-12-06:

# find. -maxdepth 1-newermt "2016-12-06" quickly find the recently modified file! Quickly find the recently modified file!

Find today's files in Linux

Important: use the correct date format as the reference time in the above find command. Once you use the wrong format, you will get the following error:

# find. -maxdepth 1-newermt "12-06-2016" # find: I cannot figure out how to interpret'12-06-2016' as a date or time

Or, use the following correct format:

# find. -maxdepth 1-newermt "12 Universe 06 Universe 2016" or # find. -maxdepth 1-newermt "12-06-16" quickly find the most recently modified file! Quickly find the recently modified file!

In this article, we explained how to use the ls and find commands to help list only today's files. Please use the feedback bar below to send us any questions or comments on this topic. You can also remind us of other commands that can be used for this purpose.

This is the end of this article on "how to quickly find recently modified files in Linux". 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 out for more people to see.

Tags: File time command format more article face letter date flag purpose error help sort search relevant good practical same important Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS vpn Shulou Tech Info MySQL OPPO Reno