Today I Learned

hashrocket A Hashrocket project

ZSH Glob Exclusion

I want to list everything except a .jpg file from the files

foo.doc foo.gif foo.jpg

but if I use print -l * I get them all back. To exclude a pattern in zsh you first must turn on extendedglob.

$ setopt extendedglob

Then, everything after the ^ will be treated as an exclusion.

$ print -l ^*jpg
foo.doc
foo.gif
See More #command-line TILs