As in the topic: I would like to remove files in a directory that have been modified in a particular date range. How can I do this ?
As in the topic: I would like to remove files in a directory that have been modified in a particular date range. How can I do this ?
The command
GNU find
is the way to go. For example, to delete all files in the current directory between 1 and 5 august, you can use the following commandIt is better to execute the command without the
-delete
action, first, to see the listing of interested files (a good substitute could be-ls
that produce an ls-like listing).Removing the
-maxdepth 1
specification will traverse all subdirectories, too.You can also specify hours, for example
Be warned to not remove single quotes, that protect spaces between date and time.
The character
!
is a negation, it should be read: newer that this date but not newer that this other date.