Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I list files modified within a directory yesterday via command line?

I'd like to list out all files with modification dates in the last n days (or even simply after Y-m-d) in a directory. It must work recursively through all subdirectories as well.

How can I do this?

Ideal output:

file.txt    Mar  26 15:15
file2.txt    Mar  27 01:15

Acceptable output:

file.txt
file2.txt

Answered! (Thanks for all the help)

$ find . -type f -mtime -1 -exec ls -lah {} \;
-rw-r--rw- 1 apache apache 18K Mar 26 08:22 ./file1.txt
-rw-r--rw- 1 apache apache 12K Mar 26 09:23 ./dir1/file2.txt
-rw-r--rw- 1 apache apache 16K Mar 26 10:24 ./dir1/dir2/file3.txt
like image 652
Ryan Avatar asked Oct 14 '25 05:10

Ryan


1 Answers

find . -type f -mtime -1 -exec ls -l {} \;

will list all files within last 24 hours, with a long listing just to confirm modification date

like image 152
Alex Avatar answered Oct 16 '25 19:10

Alex