5

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?

6
  • 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, 2011 at 18:49
  • @Daniel: The options are identical in GNU Coreutils. Also, the post explicitly mentions HP-UX, not Linux or OS X. May 2, 2011 at 18:59
  • I didn't tag mac anywhere :). I tagged unix.
    – Vladimir
    May 2, 2011 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, 2011 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, 2011 at 19:03

3 Answers 3

1
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.

1
  • 1
    find / -follow -type l -exec ls -lrt {} \;?
    – Daenyth
    May 3, 2011 at 18:16
1

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

1
0

What about:

find -exec sh -c 'readlink -f "$0" &> /dev/null || echo "$0"' {} \;
1
  • HPUX does not have readlink except as a system call in C. Unless the system has added gnu utils depots May 3, 2011 at 19:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .