Hi,

I'm writing a simple crontab script to automatically find and remove
invalid symlinks.
My initial ideas relied on readlink, etc., but looking more closely at
find(1), I thought I saw a better/faster way to do it.
I think my dilemma is best illustrated by example:

[isometry@quadric:~/test]$ ls -l 
total 4
lrwxr-xr-x    1 isometry isometry        8 May 31 02:01 invalidlink1 ->
fakedir1
drwxr-xr-x    2 isometry isometry      512 May 31 02:00 realdir1/
drwxr-xr-x    2 isometry isometry      512 May 31 02:00 realdir2/
lrwxr-xr-x    1 isometry isometry        8 May 31 02:00 validlink1 ->
realdir1/
lrwxr-xr-x    1 isometry isometry        8 May 31 02:00 validlink2 ->
realdir2/
[isometry@quadric:~/test]$ find -L . -type l -print
./invalidlink1
[isometry@quadric:~/test]$ find -L . -type l -delete
[isometry@quadric:~/test]$ ls -l
total 4
drwxr-xr-x    2 isometry isometry      512 May 31 02:00 realdir1/
drwxr-xr-x    2 isometry isometry      512 May 31 02:00 realdir2/
[isometry@quadric:~/test]$

The problem is that `find -L . -type l -print` reports only the "dud"
symlinks, but `find -L . -type l -delete` removes ALL symlinks... which
is clearly not the desired behaviour.
Obviously, I could just use `find -L . -type l -print | xargs rm` but
that's two more execs, which being a scrooge isn't what I want ;)
Can anyone see "what I'm doing wrong", devise a superior solution or
suggest a patch to fix this behaviour in find(1) ?

Thanks in advance,

- Robin


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to