grep to delete WordPress ‘crunched’ files

I’m trying to figure out how to grep a folder full of files that contain 3 versions of each file. The original and several resized versions of it. I would like to delete all files with a number 0-9 or dashes in their name with grep.

Can I simply add the characters to look for instead of (filename)?

./delete -r (filename)

Related posts

Leave a Reply

1 comment

  1. If you’re on Linux, you can use shell globbing to achieve this.

    ls *[0-9-]*
    

    If this gives you the files you want, you can delete them:

    rm -i *[0-9-]*
    

    Remove the -i if there are a lot of files.