regex - remove files when name does NOT contain some words -


i using linux , intend remove files using shell.

i have files in folder, filenames contain word "good", others don't. example:

ssgood.wmv ssbad.wmv goodboy.wmv cuteboy.wmv 

i want remove files not contain "good" in name, remaining files are:

ssgood.wmv goodboy.wmv 

how using rm in shell? try use

rm -f *[!good].* 

but doesn't work.

thanks lot!

this command should you need:

ls -1 | grep -v 'good' | xargs rm -f 

it run faster other commands, since not involve use of regex (which slow, , unnecessary such simple operation).


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -