Is there a way to find all symbolic links that don’t point anywere?
[ad type=”banner”]will give me all symbolic links, but makes no distinction between links that go somewhere and links that don’t.
You are currently doing:
The symlinks command can be used to identify symlinks with a variety of characteristics. For instance:
find -L can have unexpected consequence of expanding the search into symlinked directories, so isn’t the optimal approach.
[ad type=”banner”]
is the more concise, and logically identical command to
None of the solutions presented so far will detect cyclic symlinks, which is another type of breakage. this question addresses portability.
To recap, the portable way to find broken symbolic links, including cyclic links, is:
To display a list of the broken links, replacing ${directory} with the desired root directory Edit
To display a list of the broken links,
all one line, if there are broken links it will display them with ls -l
This will print out the names of broken symlinks in the current directory.
Works in Bash.
[ad type=”banner”]
Great article.