Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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
1  
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 can try

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

This will delete:

some-files-with-numbers0

some-files-with-numbers1

some-files-with-numbers2

...

some-files-with-numbers300

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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