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 using Ubuntu 10.04, and I have a directory with a bunch of files. We changed the naming scheme of the files a while ago, and now I want to delete all the old ones.

New Name scheme:

Old Name Scheme:

I was looking through regular expressions, and I want to see how to do it with them, but I couldn't figure it out. My limited knowledge wasn't enough to get me the right combination. I saw the ":" and thought the best way to delete the files was to say "Delete all files with a ':' in them", but no luck. I would love some guidance!

share|improve this question
Do you have installed speech recognition software? If not, talking to your computer is in fact useless. :) – dolmen Mar 26 '11 at 20:52
up vote 4 down vote accepted

Try rm *:*. That certainly works for me and if it doesn't work for you it would help if you provided the details of the error message.

It would also be possible to rename the files if there's only one per day. Automating that wouldn't be a major challenge.

share|improve this answer

If the files are really a bunch you should use find instead:

find -name '*:*' -delete
share|improve this answer
why find and not rm? just for my interest ;) – schöppi Dec 19 '10 at 22:00
Because the shell will expand rm *:* in something like rm file1 file2 ... and there's a limit for the length of a command. – cYrus Dec 19 '10 at 22:19
okay thanks ;-) – schöppi Dec 20 '10 at 15:45
You forgot to give a directory. And find will look for files not only in the given directories but also in all subdirectories. Beware! – dolmen Mar 26 '11 at 20:55

If you're after a regex, this should work:-

find . -regex '.*/*[0-9][0-9]:[0-9][0-9]:[0-9][0-9]*' -exec rm -fv '{}' \;

share|improve this answer

You must log in to answer this question.

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