Skip to content
Latchkey

find -type l: Locate and Follow Symlinks

find -type l lists symbolic links; -L tells find to follow them while walking.

Symlinks trip up artifact uploads and caches. find can list them, follow them, or single out the broken ones.

What it does

find -type l matches symbolic links themselves. By default find does not follow links; the -L option (before the path) follows them so the walk descends into linked directories and tests the target type. -xtype l finds links whose targets are themselves links or are broken.

Common usage

Terminal
find . -type l
find -L . -type f          # follow links, list real files
find . -xtype l            # broken or dangling symlinks (GNU)

Options

OptionWhat it does
-type lMatch symbolic links
-LFollow symlinks during the walk (before the path)
-PNever follow symlinks (the default)
-xtype lMatch links whose target type is a link/broken (GNU)

In CI

Following links with -L can loop forever if a link points at an ancestor directory. GNU find detects most loops and warns; BSD find may not. Prefer -P (no follow) for cleanup jobs unless you specifically need to descend into linked trees.

Common errors in CI

"find: File system loop detected" (GNU, with -L) means a symlink cycle; drop -L or exclude the offending path. -xtype is GNU only; on BSD/macOS find detect broken links with find . -type l followed by a test, since -xtype is unavailable.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →