How to delete files on the command line with regular expressions?
Posted
by Jack
on Super User
See other posts from Super User
or by Jack
Published on 2010-05-06T12:00:17Z
Indexed on
2010/05/06
12:08 UTC
Read the original article
Hit count: 253
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?
© Super User or respective owner