1834805 Members
3579 Online
110070 Solutions
New Discussion

Re: List linked files

 
SOLVED
Go to solution
Tom Gore
Regular Advisor

List linked files

Is there a way I can obtain a list of all of the linked files on my system (HP-UX 11.0)?

Thanks.
8 REPLIES 8
James R. Ferguson
Acclaimed Contributor

Re: List linked files

Hi Tom:

# find -type l

...for example:

# find /etc -type l

...JRF...
Carsten Krege
Honored Contributor
Solution

Re: List linked files

If you want a list of symbolic links on your system:

# find / -type l

If you want to find the hardlinks to a specific file, e.g. /sbin/lvchange

# cd /
# ls -li /sbin/lvchange
255 lr-sr-xr-t 1 root sys 14 Aug 20 1998 lvchange@ -> /sbin/lvchange
# find . -inum 255 -xdev

(xdev is necessary since the inode number is only unique in this filesystem).

Carsten
-------------------------------------------------------------------------------------------------
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move. -- HhGttG
A. Clay Stephenson
Acclaimed Contributor

Re: List linked files

James' answer works if you are looking for symbolic links; however, if links (and I assume you are looking for regular files)
find . -type f -links +1

if you are looking for for directories (since they always have at least 2)
find . -type d -links +2

If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: List linked files

Hi again:

I had frankly ignored hardlinks and assumed that you were interested in tracking only symbolic ones since symbolic links allow you to cross filesystem boundries.

Carsten & Clay's contributions stimulated my thinking again, and here's another thought for viewing your system:

# cd /sbin
# ls -ilR | awk '$2 ~/l/ || ($2 !~/d/ && $3 > 2)' | sort -k1n | more

This will produce a list of symbolic links and all files that are hardlinked, sorted by inode number. Obviously, as Carsten noted, you will want to analyze one filesytem at a time.

...JRF...
Tom Gore
Regular Advisor

Re: List linked files

Thanks to all. I was able to obtain my info. I redirected the output to a file, downloaded to my PC, and now I can play with it to my hearts content.

Sorry James, you only get one "10" pointer evern though you replied twice.

-TFG-
James R. Ferguson
Acclaimed Contributor

Re: List linked files

Hi Tom:

A typo, and hence a correction:

ls -ilR | awk '$2 ~/l/ || ($2 !~/d/ && $3 > 1)' | sort -k1n | more

...JRF...
Bill McNAMARA_1
Honored Contributor

Re: List linked files

I use cut/grep instead of awk, I hate awk!
Does it's name come from awkward?

Later,
Bill
It works for me (tm)
Tom Gore
Regular Advisor

Re: List linked files

Bill,

Just be glad you don't have to work with an AS400 system (or do you??). They seem to have an aversion -for the most part- to vowels in their commands (WRKSPLF, CPYFRMQRYF... yuck!). ;)