How to delete files on the command line with regular expressions?
- by Jack
Lets say I have 20 files named FOOXX, where XX is the number of the file, eg 01, 02 etc.
At the moment, if I want to delete all files lower than the number 10, this is easy and I just use a wildcard, eg rm FOO0*
However, if I want to delete specific files ina range, eg 13-15, this becomes more difficult.
rm FPP[13-15] does not work, and asks me if I wish to delete all files. Likewse rm FOO1[3-5] wishes to delete all files that begin with FOO1
So, what is the best way to delete ranges of files like this?
I have tried with both bash and zsh, and I don't think they differ so much for such a basic task?