Reputation: 158
I want to remove all files with .o extension except the specific example.o, how can I do that with rm? Edit: Environment: zsh
Upvotes: 1
Views: 1998
Reputation: 785058
In zsh
, you may use KSH_GLOB
that works as extglob
of bash
:
setopt KSH_GLOB
echo rm !(example).o
Other option is to use extended_glob
with a slightly different globbing syntax:
setopt extended_glob
echo rm (^example).o
Where ^
is used for negation.
Once you're satisfied with the output, remove echo
before rm
.
Upvotes: 2
Reputation: 2046
Could be something like this?
find -iname '*.o' -not -iname 'example.o' -execdir rm {} \;
Upvotes: 1