bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to search for symlinks pointing to directories?


From: Peng Yu
Subject: Re: How to search for symlinks pointing to directories?
Date: Sat, 18 Apr 2015 12:41:12 -0500

On Sat, Apr 18, 2015 at 11:13 AM, Eric Blake <address@hidden> wrote:
> On 04/18/2015 10:02 AM, Peng Yu wrote:
>> Hi,
>>
>> I don't see there is a way to search for symlinks pointing to
>> directories natively in find.
>>
>> This can be done by using -exec and test. But I want to avoid using
>> -exec. Is there a way to such a search natively in find? Thanks.
>
> find -xtype d \! -type d
>
> does what you want. It finds all files that are directories after
> symlink resolution, but which are not directories to begin with.
>
> In an empty directory:
> $ touch a
> $ mkdir b
> $ ln -s a c
> $ ln -s b d
> $ find -xtype d \! -type d
> ./d

OK. This is what I am looking for.

This can be used to check if a symbolic link is pointing a file, a
directory, etc. Is there a way to check if a symbolic link is broken
without enumerating all the possibilities?

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]