[lug] Re: Finding Broken Links

D. Stimits stimits at idcomm.com
Sun May 27 02:48:19 MDT 2001

SoloCDM wrote:
> On Sun, 27 May 2001, D. Stimits wrote:
> % Date: Sun, 27 May 2001 01:45:19 -0600
> % From: D. Stimits <stimits at idcomm.com>
> % Reply-To: lug at lug.boulder.co.us
> % To: lug at lug.boulder.co.us
> %
> % SoloCDM wrote:
> % >
> % > How is it possible to find links that are broken?
> %
> % Give an example...http web links? Symbolic links to non-existent hard
> % link files?
> Good point...
> Symbolic or hard links to missing or removed files on hard drives.
> Note: When you reply to this message, please include the mailing
>       list/newsgroup address and my email address in To:.
> *********************************************************************
> Signed,
> SoloCDM

I just use the option to "ls" of "--color=tty". If you do "which ls" it
might already be aliased that way. After that, you have to modify your
/etc/DIR_COLORS. Make sure your LINK type and ORPHAN are different
colors. I use these:
LINK 01;36      # symbolic link
ORPHAN 01;05;37;41  # orphaned syminks

You can also change the color of "MISSING", but it seems to show up best
if the MISSING is set to the same as ORPHAN.

If you use tcsh or csh, you can create this alias to find only symbolic
links, sort of like recursive ls for symbolic links only (.cshrc or
.tcshrc to save):
alias fnln 'find . -name "\!*" -type l -xdev -print'

You can do the same thing of course in other ways. I'm not sure what all
the different shells do to embed one command in another, but you could
do this to print all symbolic links (in color), recursively from one
ls --color=tty `fnln *`

Somewhere out there I think I have heard of a program to help maintain
symbolic links, though I don't quite remember what it was (fairly likely
it was something I read a description on from a RH 7.1 install that I'm
still working on).

D. Stimits, stimits at idcomm.com

More information about the LUG mailing list