cotec1
asked on
circular soft links
I think I have softlinks that point to themselves somewhere on my system. Is there a way to find and diagnose circular links?
yuzh - yes, you can have symbolic links point to themselves -- they just have to be in different directories...
For example, try this:
mkdir 1
mkdir 2
ln -s ./1/mylink ./2/mylink
ln -s ./2/mylink ./1/mylink
The links are now circular....
cotec1:
Here's a command that I tried out and it seems to do a little of what you want:
find -follow -type l
(that's an ell after the word "type")
It will produce an error message similar to this for each invalid symlink:
find: <link name>: No such file or directory
However, this will report ALL broken symlinks. I'm not really sure how to figure out (programatically) if the links are circular or not... But, using the output of the find command, you should be able to track this down manually -- pretty quickly, too, unless you've got tons and tons of broken links...
For example, try this:
mkdir 1
mkdir 2
ln -s ./1/mylink ./2/mylink
ln -s ./2/mylink ./1/mylink
The links are now circular....
cotec1:
Here's a command that I tried out and it seems to do a little of what you want:
find -follow -type l
(that's an ell after the word "type")
It will produce an error message similar to this for each invalid symlink:
find: <link name>: No such file or directory
However, this will report ALL broken symlinks. I'm not really sure how to figure out (programatically) if the links are circular or not... But, using the output of the find command, you should be able to track this down manually -- pretty quickly, too, unless you've got tons and tons of broken links...
You certainly can create a symlink that points to itself ...
[blowfish@blowfish blowfish]$ ls -l xyzzy
lrwxrwxrwx 1 blowfish blowfish 5 Jul 2 13:26 xyzzy -> xyzzy
Now, how did I do that?
[blowfish@blowfish blowfish]$ ln -s xyzzy .
How to find them? I will post my answer in a few moments
[blowfish@blowfish blowfish]$ ls -l xyzzy
lrwxrwxrwx 1 blowfish blowfish 5 Jul 2 13:26 xyzzy -> xyzzy
Now, how did I do that?
[blowfish@blowfish blowfish]$ ln -s xyzzy .
How to find them? I will post my answer in a few moments
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just ask yourseft a question, do you think the following command work ?
ln -s test test
The answer is NO !