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
Post a Comment