I have thousands files in format randomstring_XXXXXXXX.jpg where 'xxx' is unixtime (1388415305). Now I need to delete all files older than some (unixtime) date.

Does anyone have a solution for this?


Perl solution (untested):

perl -e 'unlink grep { ($d) = /_([0-9]+)\.jpg/ and $d < XXXXXX } glob "*_*.jpg"'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.