Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSH find modified file from certain day [closed]

I am trying to discover a modified file from a certain day. I have been using find . -mtime -2 but I need to go back even further, this past Thursday and just Thursday.

I am not anywhere near proficient in unix commands so any help would be awesome.

Thanks

like image 355
SuperNinja Avatar asked May 27 '26 07:05

SuperNinja


1 Answers

If you want to find files that were modified after last Thursday use this command

find . -newermt 'last Thursday'

Before last Thursday

find . -type f \
    -not \
    -newermt "2012-12-13 00:00:00" 

Only Thursday

find . -type f \
    -newermt "2012-12-13 00:00:00" 
    -not \
    -newermt "2012-12-14 00:00:00" 

The last Thursday was 2012-12-13. When you search any file that has modification date lower than Thursday in find it should be -not newermt '2012-12-13'. When you search Only files modified on this Thursday its lower than Wednesday but greater than Thursday. And yes you can omit 00:00:00 part if you wish.

Note: POSIX find does not have -newerXY. It has only -newer. To convert -newermt "2012-12-13 00:00:00" use this.

touch -d "2012-12-13 00:00:00" pointA

find . -type f \
        -not \
        -newer pointA
like image 192
Shiplu Mokaddim Avatar answered May 30 '26 05:05

Shiplu Mokaddim