Different types of find between dates and list / delete / move

Different types of find between dates and list / delete / move

I’ve struggled for some time with find mtime/atime/ctime but the results were not so confident sometimes and this is because how Linux is operating.

If you want to delete all the files between 2018-06-01 and 2019-01-01 you need to:

1) create two files with these dates

touch -amt 201806010000 ref1

touch -amt 201901010000 ref2

2) perform the find and list / delete / move

find . -type f -newer ref1 -a ! -newer ref2 -ls

find . -type f -newer ref1 -a ! -newer ref2 -print0 | xargs -r0 rm

find . -type f -newer ref1 -a ! -newer ref2 -print0 | xargs -r0 mv -t 2018/


Leave a Reply

Your email address will not be published. Required fields are marked *