Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recursively find all files newer than a given time

Tags:

linux

bash

Given a time_t:

⚡ date -ur 1312603983 Sat  6 Aug 2011 04:13:03 UTC 

I'm looking for a bash one-liner that lists all files newer. The comparison should take the timezone into account.

Something like

find . --newer 1312603983 

But with a time_t instead of a file.

like image 816
whatupdave Avatar asked Aug 06 '11 04:08

whatupdave


People also ask

How do I find most recently modified files in Linux?

Finding Files Modified on a Specific Date in Linux: You can use the ls command to list files including their modification date by adding the -lt flag as shown in the example below. The flag -l is used to format the output as a log. The flag -t is used to list last modified files, newer first.

What is Newermt in Linux?

newermt '2016-01-19' will give you all files which are newer than specified date and ! will exclude all files which are newer than the specified date. So the above command will give a list of files which were modified on 2016-01-18. Follow this answer to receive notifications. edited Jan 26, 2019 at 13:28.


1 Answers

You can find every file what is created/modified in the last day, use this example:

find /directory -newermt $(date +%Y-%m-%d -d '1 day ago') -type f -print 

for finding everything in the last week, use '1 week ago' or '7 day ago' anything you want

like image 109
vadonka Avatar answered Oct 17 '22 06:10

vadonka