[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to search for symlinks pointing to directories?
From: |
Eric Blake |
Subject: |
Re: How to search for symlinks pointing to directories? |
Date: |
Sat, 18 Apr 2015 10:13:50 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
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
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature