Use find command to locate files newer than specific time in Linux

This tutorial will teach you how to use find command to locate files new than specific time in Linux. According to man pages, find command is used to search for files in a directory hierarchy.

Use find command to locate files newer than specific time in Linux

Find command is usually installed by default on any Linux system.

The basic command line syntax for find command is:

find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression]

In this tutorial, we will go through a few examples on how use find command to locate files newer than specific time in Linux.

Thus, open your terminal and navigate to the directory/folder you want to search for the files.

Alternatively you can open terminal directly from that directory by right clicking in the directory and selecting open in terminal on the menu that will display.

Find files newer than 30 minutes

To locate files new then 30 minutes run the following command

find . -type f -newermt '30 minutes ago' -print

Where:

  • find – it’s the command name
  • dot(.) – means the current directory/folder. You can replace this with the absolute path of the file, for example, /var/log.
  • -type f – means of type file
  • -newermt – means newer than the time inputted
  • -print – display the files

Find files newer than 1 day

To locate files new than 1 day run the following command:

find . -type f -newermt '1 day ago' -print

Find files newer than 1 year

To locate files new than 1 year run the following command:

find . -type f -newermt '1 year ago' -print

Find files newer than 1 Week

To locate files new than 1 week run the following command:

find . -type f -newermt '1 week ago' -print

Find files newer than 1 Month

To locate files new than 1 month run the following command:

find . -type f -newermt '1 month ago' -print

Find files newer than Specific date

You can also find files new than using specific date e.g. 20/03/2020, by running the following command:

find . -type f -newermt '20 march 2020' -print

Find files newer than Specific date and Time

To find files new than from specific date and time run the following command:

find . -type f -newermt '20 march 2021 18:00:00' -print

Find files new than specific date to specific date

To find files new than specific date to specific date run the following command

find . -type f -newermt "2021-05-01" ! -newermt "2021-10-20"

And that is how easy it is to use find command to locate files newer than specific time in Linux.

Read more on Linux man pages.

man find

Other Tutorials

How to Use uname Command on Linux

How to Use fdisk Partitioning Tool on Linux

Example Usage of df Command on Linux

System administrator | Software Developer | DevOps

Leave a Comment