Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: globbing on symlink target



On Wed, Feb 28, 2018 at 9:59 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Wed, Feb 28, 2018 at 11:31 AM, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>> On Wed, Feb 28, 2018 at 7:42 PM, Eitan Adler <lists@xxxxxxxxxxxxxx> wrote:
>>> Is it possible to glob on a symlink target rather than the symlink
>>> name.
>>
>> % ls -l *(@)
>> lrwxrwxrwx 1 mikaelh users 3 Feb 28 16:50 broken -> foo
>> lrwxrwxrwx 1 mikaelh users 3 Feb 28 20:27 broken2 -> bar
>> lrwxrwxrwx 1 mikaelh users 3 Feb 28 20:27 hello -> foo
>> % echo *(e*'local -A foo; zstat -LH foo $REPLY; [[ $foo[link] == foo ]]'*)
>> broken hello
>
> Should be easier than that -- using Eitan example of files with a
> ".rb" extension:
>
> % ls *(@e^'[[ $REPLY:P = *.rb ]]'^)

Ah, that is indeed easier. I think you can't differentiate relative or
absolute symlinks with this method though, if you happen to care about
that.

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author