Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Globbing symlinks-to-${glob_qualifier}
On Wed, Aug 18, 2021 at 7:32 PM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
>
> How can I glob for all symlinks-to-symlinks-to-a-directory (etc)?
You can run a function from a glob qualifier by using the "e"
qualifier or its shortcut "+". So it's possible to do almost anything
you want, it just might be slow.
This one shouldn't be too laggy.
zmodload zsh/stat b:zstat
function _ { # Chosen as a short name
local -a L
zstat -A L +link $REPLY && [[ -h $L ]]
}
# Print all symlinks to symlinks
print -r -- *(+_)
# Print symlinks to symlinks to directories
print -r -- *(+_-/)
In the last case (as Lawrence noted in a message that came in while I
was typing this) the "-" is going to run down the entire symlink chain
to find the ultimate target, i.e., you can't tell if there are exactly
two symlinks, just that there are at least two.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author