tips
12 tips Globbing
One command, setting or habit at a time about Globbing: what it does, the line to copy and a caveat or two.
Globbing 12
-
Preview a pattern-based bulk rename in zsh before running it.
zmv -n '(*).log' '$1.txt' -
Brace expansion can pad numbers with zeros and skip values with a step.
echo {01..10} -
Controls whether a pattern like .* also matches the current and parent folder entries.
shopt globskipdots -
Switches off filename expansion in the current shell, so a * is passed on as a plain character.
set -f -
Keep *.bak or *~ files out of every * you type in that session.
GLOBIGNORE='*.bak:*~' -
Pick files by a digit or letter in a fixed spot, without regex.
ls -
Match photo.JPG and photo.jpg with one pattern.
shopt -s nocaseglob -
Match a list of extensions without the empty results that braces leave.
shopt -s extglob -
Lets the * wildcard include files whose names start with a dot.
shopt -s dotglob -
Makes a bash glob that matches no files disappear, so loops skip instead of failing.
for f in *.log; do -
Lists or selects every file except the ones matching a pattern, using Bash extended globs.
shopt -s extglob -
Turns on ** in Bash so one pattern matches files in every subfolder.
shopt -s globstar
Nothing in this filter yet.