Exclude one pattern from glob match
shopt -s extglob
echo rm foo.!(org)
This is "foo." followed by anything NOT "org"
ref: https://www.gnu.org/software/bash/manual/bashref.html#Pattern-Matching
In bash, you can also use GLOBIGNORE="*.org"; rm -i foo*
.
And unset GLOBIGNORE
when done.
It's not really better than shopt -s extglob
, but I find it easier to remember.
A pipe can do?
ls * | grep -v "foo.org" | xargs -I {} echo {}
(obviously you might want to replace echo with rm in the last chain).