Yannick Le Saint (kyncani) wrote:
On Sun, 2003-11-30 at 13:23, Andrew Gaffney wrote:

I recently installed tripwire on one of my Gentoo servers. Everytime I run it, I get ~250 warnings about files not existing, which are symlinks pointing to nothing. How can I find all invalid symlinks and delete them? Thanks.


( for f in $(find / ! -fstype proc -type l 2>/dev/null); do cd $(dirname
"$f") 2>/dev/null && ! test -e "$(readlink "$f")" && echo "$f"; done )

 This would print your broken symbolic links, just take any action you
want about it later.

I've modified the script as follows and it only finds 4 invalid symlinks. Do the above and below do the exact same thing?


for f in $(find / ! -fstype proc -type l 2>/dev/null); do
  cd `dirname "$f"` 2>/dev/null
  if [ ! -e `readlink "$f"` ]; then
    echo $f
  fi
done

--
Andrew Gaffney


-- [EMAIL PROTECTED] mailing list



Reply via email to