I'm working on a HP-UX system and I want to find if there are any circular symbolic links.

So far I'm using the command:

ls -lrt  `find ./ -follow -type l`

But it's only doing ls -lrt on current directory as result.

What command should I use to find all circular symbolic links in a system?

link|improve this question
ls -lrt? long format, sort by time modified, reversed? Did you mean to tag linux? Because on a Mac, these options don't make sense. – Daniel Beck May 2 '11 at 18:49
@Daniel: The options are identical in GNU Coreutils. Also, the post explicitly mentions HP-UX, not Linux or OS X. – grawity May 2 '11 at 18:59
I didn't tag mac anywhere :). I tagged unix. – Vladimir May 2 '11 at 19:00
@grawity Huh. OK. I thought they maybe did something interesting on a GNU/Linux machine. Switching between Mac/Linux systems is generally a pain because of the command line arguments, so I just had to ask. – Daniel Beck May 2 '11 at 19:01
@user Mac OS X is a certified Unix system based on BSD. While you didn't specifically tag osx, I didn't completely ask without a reason. There is btw no -follow argument to find in Unix — I assume that's GNU only. – Daniel Beck May 2 '11 at 19:03
show 1 more comment
feedback

3 Answers

maybe this answer helps: How do I find circular symbolic links?

link|improve this answer
It's the same question... – Stéphane Gimenez Jul 24 '11 at 0:10
feedback
ls -lrt  `find / -follow -type l`

./ searches the current directory. If it happens to be / then your command as you wrote it will search from the root directory. Otherwise lose the leading dot.

link|improve this answer
find / -follow -type l -exec ls -lrt {} \;? – Daenyth May 3 '11 at 18:16
feedback

What about:

find -exec sh -c 'readlink -f "$0" &> /dev/null || echo "$0"' {} \;
link|improve this answer
HPUX does not have readlink except as a system call in C. Unless the system has added gnu utils depots – jim mcnamara May 3 '11 at 19:22
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.