From: Bart Schaefer <schaefer@brasslantern.com>
To: Zach Riggle <zachriggle@gmail.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Compound Glob Specifiers
Date: Mon, 8 Nov 2021 19:30:29 -0800 [thread overview]
Message-ID: <CAH+w=7YUS+c2DbwS1UvC22G27-A69g2e8BMTA5X0D102Wi03HA@mail.gmail.com> (raw)
In-Reply-To: <CAMP9c5kG4cR7QxMu93cLeZn_4BmZht=toAijxj4GvnKbYMm5Gw@mail.gmail.com>
On Mon, Nov 8, 2021 at 3:03 PM Zach Riggle <zachriggle@gmail.com> wrote:
>
> It would then follow that *(/)/*(/)/somefile would match dir/dir/somefile and not dir/link/somefile.
Lawrence also said this, but since I've already typed it ...
Parenthesized qualifiers can't appear in the middle of a glob. The
stat() etc. calls that implement the qualifiers are only applied after
the full path name is generated. Manual in section 14.8.7 says --
Patterns used for filename generation may end in a list of qualifiers
That means the whole pattern, not individual path segments. The only
things you can put elsewhere are the flags listed in 14.8.4.
> I want to glob the equivalent of */*/somefile (not **/foo, specifically two directories deep).
If your tree is not excessively deep, you can do it like this (assumes
extendedglob)
% ls **/somefile~*/*/*/*
This says "find all somefile below here, without following symlinks,
and then throw away any names that contain three slashes" (which
includes any that have more than three).
For a tree deep enough to cause **/ to be slow, you have to get
fancier (and this doesn't require extendedglob):
% ls */*/somefile(e^'[[ $REPLY:a = $REPLY:P ]]'^)
The fun thing about that last one is that if you replace "=" with "!="
you can find all the paths that DO have symbolic links.
next prev parent reply other threads:[~2021-11-09 3:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-08 23:03 Zach Riggle
2021-11-09 3:04 ` Lawrence Velázquez
2021-11-09 3:30 ` Bart Schaefer [this message]
2021-11-09 7:52 ` Mikael Magnusson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH+w=7YUS+c2DbwS1UvC22G27-A69g2e8BMTA5X0D102Wi03HA@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=zachriggle@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).