Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|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

3 Answers

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

share|improve this answer
    
It's the same question... –  Stéphane Gimenez Jul 24 '11 at 0:10
add comment
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.

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

What about:

find -exec sh -c 'readlink -f "$0" &> /dev/null || echo "$0"' {} \;
share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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