Hm... say I wanted to remove all mp3 files from a certain directory, I'd use "rm -f *.mp3"... what would I do if I wanted to remove everything /but/ mp3 files?

Sure, I /could/ move the mp3 files to somewhere else and delete the original folder I guess, but meh.

@Morgan @maunzikation rm $(ls | grep -v '\.mp3$')

Test it first by replacing rm with echo…

Explanations : -v means "everything BUT". $(command) means "executes this command and replace the $(stuff) by the result of the command"

Sign in to participate in the conversation
Computer Fairies

Computer Fairies is a Mastodon instance that aims to be as queer, friendly and furry as possible. We welcome all kinds of computer fairies!