this post was submitted on 30 Jun 2026
51 points (100.0% liked)

Linux

14231 readers
691 users here now

A community for everything relating to the GNU/Linux operating system (except the memes!)

Also, check out:

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 3 years ago
MODERATORS
 

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

you are viewing a single comment's thread
view the rest of the comments
[–] IanTwenty@piefed.social 11 points 1 week ago* (last edited 1 week ago)

Presuming BASH:

https://www.gnu.org/software/bash/manual/bash.html#Quoting

Single quotes are much safer/predictable because:

Enclosing characters in single quotes (‘'’) preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash.

Not to say they are always the right choice though.