[nSLUG] Command line fu

Daniel Morrison draker at gmail.com
Sat Sep 12 16:11:34 ADT 2009

2009/9/12 Rich <budman85 at eastlink.ca>:
> Find broken symlinks  (not sure which version they added xtype, may not work on all systems)
>    find . -xtype l

-xtype has been in GNU findutils at least since the initial revision
was entered into their source code repository in 1996 (version 4.1).

But you might be on a Mac which lacks -xtype, so:

My reading of the man page suggests that -xtype may be a convenience option for:

find -L . -type l

...which is virtually the same as:

find . -follow -type l

Follow symbolic links, and check the type of the target. The target
can never be a link[*], so the type check always fails, _unless_ the
link could not be followed (i.e. is broken).

However I do find the man page to be quite complex and confusing, so I
may not have it completely correct. Seems to work for me.


[*] the target could be a link if you have an infinite loops of links
pointing back to each other, but in this case you get an error: "Too
many levels of symbolic links"

More information about the nSLUG mailing list