Piksel’s stencil over the shelf’s labels: * ? [..] expanded by a model bash before the command runs. Dotfiles, a pattern that matches nothing, and quotes for…
Globs are in every command: cp, rm, ls, find, .gitignore, CI scripts. "Why does * miss .env", "why does rm *.bak say No such file", "why is find -name *.txt odd": all of it is bash expanding the pattern before the program runs.
bash expands a pattern into names before the program runs
cp * backup/ quietly skips .env A glob skips dotfiles. Use a pattern starting with a dot (.* or .[!.]*), or copy the folder: cp -r folder/. backup/.rm *.bak says No such file when I only wanted to delete them if any With no match bash passes the literal pattern on, and rm looks for a file named *.bak. rm -f *.bak stays quiet; shopt -s nullglob makes an unmatched pattern vanish.* in a glob is * in a regex A glob * = a regex .*. A glob has no + or "repeat the character before"; regexes are for grep, globs are how bash matches file names.find . -name *.txt finds only some, or errors bash expands *.txt first, in this folder. Quote the pattern: find . -name '*.txt', so find matches it in every folder.* into several names See the stencil let the matching names through, sorted.? for exactly one character photo?.jpg leaves photo10.jpg out.[…] data.[cj]* or [!cdf]*: one character from (or outside) the set..* * skips them on purpose; a pattern starting with a dot catches them.