From Wiki-UX.info

Wiki-UX / File Systems / How to find orphan symbolic links
Jump to: navigation, search

How to find orphan symbolic links

Abstract

This article describes a Postfix Shell script to check for orphan (miss) symbolic links in a file system.

for link in `find <filesystem> -type l`
do
   if [ ! -e $link ]; then echo $(ll $link | tr -s ' ' | cut -d " " -f 9-11) ; fi
done

For example:

# cd /home
 
# echo "test" > test
 
# ln -s test test1
 
# rm test
 
# for link in `find /home -type l`
do
   if [ ! -e $link ]; then echo $(ll $link | tr -s ' ' | cut -d " " -f 9-11) ; fi
done
/home/test1 -> test

Reference

Authors

This page was last modified on 17 July 2010, at 03:20. This page has been accessed 2,320 times.