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 want to clean out my music library so I don't get any more "search for suitable plugin" messages from Rhythmbox when it sutubles across some WMA-Relic.

I have the tools, but now I want to FIND these files. I can get a list of all music files with ls, then pipe this to grep and catch all the mp3s like this:

ls */* | grep \.mp3$

Now I want to filter OUT all the MP3s, how would I do that? I messed around a lot with ^ and ~ and ! but I never seemed to get anywhere. I KNOW for a fact there are a few WMAs in there, but why should I search manually when I have a computer xD

Can anyone help?

share|improve this question
up vote 12 down vote accepted

grep -v will return all lines that don't match your search query

you can also use:

find . ! -name "*.mp3"

to do the whole thing in one command.

share|improve this answer
To be on the safe side, I'd go with -iname rather than -name to perform a case insensitive match. You may or may not have some .MP3 files sitting around, etc... – jonathanserafini Feb 17 '10 at 13:08

Have a look at the -v switch to grep, which inverts matching.

share|improve this answer

Your Answer


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