Saturday, 16 February 2019

linux - grep - match anything but given filetype


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?



Answer



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.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...