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 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:

>1afsd.
>12fdfd
>12dfad
>23fdfa1
>fdafad!

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 stackoverflow.com Sep 27 '11 at 3:43

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

1  
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: en.wikipedia.org/wiki/Glob_%28programming%29 – Cory Kendall Sep 25 '11 at 7:25
2  
The * symbol matches zero or more occurrences of any characters. – Keith Thompson Sep 25 '11 at 7:29

You must log in to answer this question.

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