How to find broken soft links in a directory?

How to find broken symbolic links in a directory which have many symbolic links?

Use this command to find broken soft links:

find -xtype l /path/to/dir/to/find/in/

You can also specify the action by -exec. For example, delete the soft links that are broken in the current directory:

find -xtype l -exec rm -f {} ;

Not /path/to/dir/to/find/in/ specified here, which means . (the current directory).

Answered by Eric Z Ma.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *