Rene Kita's weblog

Blog About RSS Links

Globbing in zsh

Because I always forget one of those...

This needs setopt extendedglob to work.

Files not ending in ~:
ls patches/^*~

Files not ending in ~ and not ending in .orig:
ls patches/^*(~|.orig)

.patch files without .origs and backups:
ls patches/*.patch^(~|.orig)

Files without an extension:
ls t/^*.*

Regular files not ending with .o:
ls ^*.o(.)

Directories only (recursively):
ls **/*(^/)

Regular files only (recursively):
ls **/*(.)

Remove *.rej and *.orig w/o erroring out if _one_ does not exist:
rm *.rej(N) *.orig(N)

Numbered files with numbers above 21:
ls *<22->

Last modified: 2023-04-13T12:36:57Z