Home Linux Commands How to Find Files That Have Been Modified in Last 24 Hours

How to Find Files That Have Been Modified in Last 24 Hours

As our digital lives become increasingly dynamic, managing files efficiently is crucial. One common task is to find files that have been recently modified to stay on top of changes or track activities.

Whether you are a developer, system administrator, or a regular computer user, knowing how to identify files modified within the last 24 hours can be incredibly valuable.

In this article, we will explore how to achieve this using the powerful find command on Unix-based systems.

Finding Files Modified Within the Last 24 Hours

The find command is a powerful and efficient utility employed to locate files and directories based on various criteria, including modification time, creation time, and access time within your Linux system.

To search for files based on their modification time, the “find” command offers the "-mtime" option allows us to search for files based on their modification time, which is measured in days.

1. find Command with -mtime Option

To search for all the files in the “Downloads” directory that have been modified/altered exactly 24 hours ago, execute the command below.

$ find ~/Downloads -type f -mtime 0

If you want to search the entire system, you can use the root directory /, but be aware that this can be time-consuming and may return a vast number of results.

$ find / -type f -mtime 0

If you want to search for files within the current directory and its subdirectories, use the following command.

$ find . -type f -mtime -0
Find Files Modified 24 hours Ago
Find Files Modified 24 hours Ago

Here is the breakdown of the above command:

  • The -type f option ensures that only regular files (excluding directories and other special files) are included in the search results.
  • The -mtime -0 option restricts the search to files modified within the last 24 hours ago.

You can even utilize the value “-1” for the “-mtime” flag in the find command to get all the files that are updated within 24 hours.

$ find ~/Downloads -type f -mtime -1
Find Files Modified Within 24 Hours
Find Files Modified Within 24 Hours

The “1” in the above command represents the number of days, while the negative sign indicates “Less Than”. In short, it will search for files modified within the last 24 hours.

2. find Command with -mmin Option

Moving forward, let’s explore another option of the “find” command named "-mmin" (stands for “Modification Minutes“), which is used to search for files based on their modification time in minutes instead of days.

$ find ~/Downloads -type f -mmin -1440
Find Files Based on Modification Time
Find Files Based on Modification Time

In the above command, the "-1440" indicates “less than 1440 minutes,” with the value derived by converting 24 hours into minutes (24 hours * 60 minutes).

3. find Command with -newermt Option

The -newermt option is used to find files based on their modification time but unlike the -mtime and -mmin options, which allows us to specify an exact date and time rather than a relative time period.

$ find ~/Downloads -type f -newermt "24 hours ago"
Find Files Based on Specified Time
Find Files Based on Specified Time

While discussing the "-newermt" flag, let’s delve into another argument, “1 day ago” which serves the purpose of finding files that have been modified within the past day:

$ find ~/Downloads -type f -newermt "1 day ago"

You can also find files modified on a certain date (regardless of the time):

$ find ~/Downloads -type f -newermt "2023-08-05"

4. Using ls and Grep Commands

Lastly, let’s discuss another cool command that combines the “ls” and "grep" commands to look for files modified within the last 24 hours.

$ ls -lt ~/Downloads | grep 'Jul 21'
List Modified Files on Specific Date
List Modified Files on Specific Date
Conclusion

Being able to quickly find files that have been modified within the last 24 hours is a valuable skill for anyone working with files on Unix-based systems.

Thanks to the find command and its flexible options that offers a straightforward and efficient way to locate files modified within the last 24 hours.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.