Re: [gentoo-user] finding invalid symlinks
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
Re: [gentoo-user] finding invalid symlinks
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 is giving me output like: dirname: too few arguments Try `dirname --help' for more information. -bash: /usr/local/man: is a directory /usr/local/man dirname: too few arguments Try `dirname --help' for more information. -bash: /usr/local/doc: is a directory /usr/local/doc dirname: too few arguments Try `dirname --help' for more information. -bash: /usr/include/X11: is a directory /usr/include/X11 dirname: too few arguments Try `dirname --help' for more information. -bash: /usr/include/GL: is a directory /usr/include/GL -- Andrew Gaffney -- [EMAIL PROTECTED] mailing list
Re: [gentoo-user] finding invalid symlinks
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. -- [EMAIL PROTECTED] mailing list