Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a folder which has many files. Some of the data files are labelled 1, 2, 3, ..., 300

I want to remove these data files using the terminal. How do I do this?

I want to do something like

rm some-regular-expression-giving-numbers-from-0--300
share|improve this question
Are they just called 1, 2, etc. and do they all match an expression that gives numbers from 0 to 300, or are there any other elements in the filename? Can you give us a more concrete example, maybe with a directory listing? – slhck Jul 15 '12 at 18:23
Yes they are just called 1, 2, etc. – smilingbuddha Jul 15 '12 at 18:39

You can try

rm some-files-with-numbers{0..300}

This will delete:





share|improve this answer
awesome! thanks! – ozOli Jul 2 '15 at 9:11

I like superuser’s answer, but to add another possibility:

find . -regex './some-files-with-numbers[123]?[0-9]?[0-9]' -delete
share|improve this answer
What about some-files-with-numbers301? – cYrus Jul 15 '12 at 18:50
@cYrus I am aware of the limitations :) My answer was more aimed at being an alternative to superuser’s one. – qdii Jul 15 '12 at 20:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .