How do I list files modified on or before particular date?

4

1

Using linux commands , is there way to list files which are created an hour (or particular date) before ?.

sudurais

Posted 2011-05-20T00:51:19.627

Reputation: 217

Answers

4

you can use the find command along with -mmin and -mtime flags. For example to list *.txt files in Downloads folder modified more than 30 days ago use this:

find $HOME/Downloads -name  '*.txt' -mtime +30

+ implies more than

smokinguns

Posted 2011-05-20T00:51:19.627

Reputation: 1 188

Valid answer, but a note to Original Question: this depends on the file metadata stored with on the filesystem. This can be reset by the touch command. In short, you can never know 100% when it was changed. – Rich Homolka – 2011-05-20T23:10:32.387

@Rich. Thanks for sharing the note. I agree. In my reqs, I wanted to cleanup iso files built doing last compliations. it takes so much space. So, I wanted to cleanup everytime after successful completion of build. – sudurais – 2011-05-22T05:12:45.750

1

The find command's -mmin and -mtime predicates can select files based on their mtime.

Ignacio Vazquez-Abrams

Posted 2011-05-20T00:51:19.627

Reputation: 100 516