Skip to content
Advertisement

Delete logs that ended with date format

I created the following cli in order to delete the logs with date format that oldest then 500 min

date format is:

JavaScript

the cli that should removed the logs

JavaScript

as we can see the logs still exists

JavaScript

where I am wrong?

Advertisement

Answer

Your regex does not match the files. Change

'.*.log.[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2,10}$'

for

'.*.log.[0-9]{4}-[0-9]{2}-[0-9]{2,10}$'

since there’s no third hyphen (nor fourth date field).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement