Operating System - HP-UX
1833750 Members
2305 Online
110063 Solutions
New Discussion

Re: hard link base on inode number

 
Steve_3
Frequent Advisor

hard link base on inode number

Is there a way to create a hard link base on inode number?

Thanks,
Steve
5 REPLIES 5
Patrick Wallek
Honored Contributor

Re: hard link base on inode number

I don't think you can do any kind of links based on inode number.

The only options for a link (hard or symbolic) are directory name or file name.

I am curious as to why you want to create a link based on inode #?
Steve_3
Frequent Advisor

Re: hard link base on inode number

This was an open file. The file is gone but the process still has the inode. So I am trying to recover the file base on the inode.
Madhu Sudhan_1
Respected Contributor

Re: hard link base on inode number

In this case I think find can be your best friend.

find / -inum -exec ll {} \;

Hope this helps.

...Madhu
Think Positive
Pramod_4
Trusted Contributor

Re: hard link base on inode number

Hi,

I think madhu is correct. If you still have the data blocks associated that said inode number you would be able to recover it.

If it is a text file the following command should help you out:

find /< name of the dir> -inum < inode num> -exec cat {} ;\ > /tmp/abc

Cheers,

Pramod
Patrick Wallek
Honored Contributor

Re: hard link base on inode number

I agree with Madhu and Pramod. Find is probably your best bet. Another option if it is not a text file to see what the file was is:

find /dir -inum inode# -exec strings {} \;