Rene Kita's weblog

Blog[0] About[1] RSS[2] Links[3]

Globbing in zsh

2023-04-13

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 *

Files sorted by mtime, youngest first:
ls *(om)

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

E-mail: mail@rkta.de[4] IRC: #rkta[5] on Libera.Chat[6]

Copyright (c) 2017-2024 Rene Kita

=> [0] Blog | [1] About | [2] RSS | [3] Links | [4] mail@rkta.de | [5] #rkta | [6] Libera.Chat

Proxy Information
Original URL
gemini://rkta.srht.site/zsh-globs.gmi
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
222.764257 milliseconds
Gemini-to-HTML Time
0.537756 milliseconds

This content has been proxied by September (3851b).