Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 am doing some practice question off a text book and I ran into one thing that I cannot seem to solve. It wants us to remove all files that

  • start with a number and
  • end is not a letter

So I use Linux and created a few empty files like this:


I tried with this command

rm -i [0-9]

which only removes the ones that have number in it

rm -i *[!a-zA-Z]

which only remove the one that does not have a letter at the end.

Is there a way for it to do both? I tried

rm -i [0-9]* *[!a-zA-Z]

but it's just the same command ran twice. How do I combine them?

Note: I am using the -i so I don't delete the file or I have to recreate them every time.

share|improve this question

migrated from Sep 27 '11 at 3:43

This question came from our site for professional and enthusiast programmers.

why not rm [0-9]*[!a-zA-Z]? – sinelaw Sep 25 '11 at 7:09
up vote 2 down vote accepted

I think

rm -i [0-9]*[!a-zA-Z]

should work.

share|improve this answer
ah so the * symbol remove everything in between? – ricedragon Sep 25 '11 at 7:24
@ricedragon the * symbol matches any character. Check this out for some more in depth info: – Cory Kendall Sep 25 '11 at 7:25
The * symbol matches zero or more occurrences of any characters. – Keith Thompson Sep 25 '11 at 7:29

Your Answer


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.