I have some logs files with
somefiles.log.YYYY-mm-dd
and I want to delete those files that are older than N days base on the timestamp in its filename.
I have some logs files with
somefiles.log.YYYY-mm-dd
and I want to delete those files that are older than N days base on the timestamp in its filename.
Better delete based on creation time using find:
use cut command to retrieve YYYY-MM-dd part of filename. and use date command as following to convert it to time_t type.
then you can compare time_t to determine which file should be deleted.