Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Compound Glob Specifiers
- X-seq: zsh-users 27334
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zach Riggle <zachriggle@xxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Compound Glob Specifiers
- Date: Mon, 8 Nov 2021 19:30:29 -0800
- Archived-at: <https://zsh.org/users/27334>
- In-reply-to: <CAMP9c5kG4cR7QxMu93cLeZn_4BmZht=toAijxj4GvnKbYMm5Gw@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAMP9c5kG4cR7QxMu93cLeZn_4BmZht=toAijxj4GvnKbYMm5Gw@mail.gmail.com>
On Mon, Nov 8, 2021 at 3:03 PM Zach Riggle <zachriggle@xxxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author