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 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
add comment

1 Answer 1

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
add comment

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.