I have a directory with a bunch of folders named in yyyy-MM-dd
format. I want to delete all the folders where the yyyy-MM-dd
string is older than X days.
# ls
2018-01-01
2018-01-02
2018-01-03
...
2018-02-01
2018-03-05
...
2019-01-02
2019-01-02
Is it possible to find like this?
Update:
This question is not a duplicate of Delete files older than specific date in linux because that talks about finding files by mtime
and I want to find by file name where the file name matches a date string. For example, the name of a directory could be 2012-01-01
but it's mtime
could be 2018-03-11
. This is why mtime
or any of the other date/time metadata will not work for my needs.