how can i find top 10 files in unix with most links to it?
This seems to work:
If you want the number of files shown to be other than 10, then just add the number you want as an argument to
This will search for symlinks below the current directory, to search over another directory, replace the
Output will be sorted in order of decreasing link count. (-r = reverse, -n = numeric sort, -k 4 = sort on column 4)
If you want symlinks, then you'll have to look at the other answers. I answered the only interpretation that has an easy answer. :P
I don't believe there's anything about a file which tells you how many links there are to it.
If I'm right, you'll have to search your directory tree for links and sort them by the file they link to.
to list links. Then redirect the output to
I haven't tested this (it's not complete, anyway): I'm not sure if I have any duplicated links to find in my filesystem which would make a test meaningful.