Operating System - HP-UX
1823332 Members
3345 Online
109654 Solutions
New Discussion юеВ

Re: HPUX : Find Command , Locating soft and hard links

 
SOLVED
Go to solution
LG Porter
Frequent Advisor

HPUX : Find Command , Locating soft and hard links

HPUX 10.20 I need to migrate a exsisting application to another system, can the "find" command be used to locate and identify all of the soft links with are now in place on the old system?
11 REPLIES 11
Chris Wilshaw
Honored Contributor

Re: HPUX : Find Command , Locating soft and hard links

find / -type l -print

Chris
Christopher McCray_1
Honored Contributor
Solution

Re: HPUX : Find Command , Locating soft and hard links

Hello,

# find / -type l -exec ll {} \; > linkfile

Hope this helps

Chris
It wasn't me!!!!
Tom Maloy
Respected Contributor

Re: HPUX : Find Command , Locating soft and hard links

find -type l /

will find all of the symbolic links.

Tom
Carpe diem!
T G Manikandan
Honored Contributor

Re: HPUX : Find Command , Locating soft and hard links

find /home -type l -print

Thanks
Sajid_1
Honored Contributor

Re: HPUX : Find Command , Locating soft and hard links

Hi,

what about using -type l option:
# find / -type l ..

this will list all symbolic links. Read the man pages and check if you need to use the -follow option too.
learn unix ..
S.K. Chan
Honored Contributor

Re: HPUX : Find Command , Locating soft and hard links

You can use "-type l" option in find. Check "man find" for details. For example ..
# cd /opt
# find . -type l -exec ls -sl {} \;
==> List all symbolic links recursively in /opt.
Stefan Farrelly
Honored Contributor

Re: HPUX : Find Command , Locating soft and hard links

Soft links are easy - use the find commands as previously listed. Hard links are tougher. You will need to use the ls -l option. If this value is > 1 then they are linked.

eg.
cd /usr/sbin
ll vg*
You will see the link count at 31 - all these programs are hardlinked to each other. They have the same sum values also.I think it best to do a sum on all files and those with the same sum value are hardlinks to each other.

Im from Palmerston North, New Zealand, but somehow ended up in London...
Hai Nguyen_1
Honored Contributor

Re: HPUX : Find Command , Locating soft and hard links

LG Porter,

Yes you can do it with this command run by root.

# find / -type f | more

or redirect to a file.

Hai
Hai Nguyen_1
Honored Contributor

Re: HPUX : Find Command , Locating soft and hard links

LG Porter,

instead of:

# find / -type f | more

I actually meant this:
# find / -type l | more

Hai
Rich Wright
Trusted Contributor

Re: HPUX : Find Command , Locating soft and hard links

For hard links, you need to understand that every file name that references an inode number is a hard link.
For example if you enter the following command:
ls -li /sbin/vg*

You will see that all of the vg... comands are really one executable file because the inode is the same. They just perform differently when the code determines what hard link name was used.
Rodney Hills
Honored Contributor

Re: HPUX : Find Command , Locating soft and hard links

To search for hard links, try this one liner-

ncheck /dev/vg00/lvol5 | sort -n | awk '$1==prev{print last;print $0}{prev=$1;last=$0}' | uniq

Where /dev/vg00/lvol5 can be replaced with whatever filesystem you wish to scan.

This will produce of a list of all filenames that share the same i-node with at least one other file.

for instance, here are some of the files displayed for /dev/vg00/lvol6 (/usr on my system).

29094 /share/lib/terminfo/5/50
29094 /share/lib/terminfo/w/wy50
29094 /share/lib/terminfo/w/wyse50
29116 /share/man/man1m.Z/mount_cdfs.1m
29116 /share/man/man1m.Z/umount_cdfs.1m

The first number is the common i-node number. The filename that follow is relative to the filesystem you are scanning.

Depending on the number of files in the filesystem, it could take a while to run.

-- Rod Hills
There be dragons...