I came across this older article from 2020 and I found it informative. It’s about how the shell does globbing and the potential issues it can cause if not understood correctly.
TLDR:
find . -not -name *.py -delete and find . -not -name '*.py' -delete will behave differently in certain scenarios.
In the first example, the shell will replace the wildcard pattern with a list of matching
file names IF there are any matches in the current directory. If there isn’t, then it
won’t do anything and will pass *.py to find.
In the second example, the shell won’t do any globbing at all and will just pass *.py


Basic habit to get into:
If you’re contemplating doing something destructive, do a dry-run first.
In this case, remove the
-deleteflag, run the command and see what you get.A good approach is to build a command step by step and test your assumptions each iteration.
Things might take a few moments longer, but one day it’s going to save your bacon.
As for unexpected globbing, learn the difference between quoted and unquoted, and single versus double quotes.
Source: Linux user for 25+ years
What’s the difference between single vs double quotes?
Presuming BASH:
https://www.gnu.org/software/bash/manual/bash.html#Quoting
Single quotes are much safer/predictable because:
Not to say they are always the right choice though.
The shell doesn’t expand or interpolate single-quoted strings, they are literals
@vk6flab@lemmy.radio is a WITCH I tell you! This is black magic!!