Operating System - HP-UX
1833785 Members
2541 Online
110063 Solutions
New Discussion

hard link file , conceptual question

 
SOLVED
Go to solution
machoq1
Esteemed Contributor

hard link file , conceptual question

I have a file which has 19 links all having the same inode.
I need to copy a new version of the file over the existing file.

will a cp NewFile OrigFile preserve the inode of OrigFile?

If not then how can i preserve the inode number without cutting and pasting contents of new file over the new file ?
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: hard link file , conceptual question

If you cp to an existing file, the existing file's inode number will be preserved. One way to deal with this so that inode numbers are not important is to create symbolic links. Npte a that a symbolic link can exist for a file that does not exist at the time of creation.
If it ain't broke, I can fix that.
Simone Del Pinto
Trusted Contributor

Re: hard link file , conceptual question

Hi Sacket,

try th " cp -p" command...

... Ithink that this is good for you! :-)

Regards,

Simone Del Pinto
I love Forum ITO
Rodney Hills
Honored Contributor

Re: hard link file , conceptual question

All 19 hard links have just one inode. The 17 directory entries all point to the same inode.

A "cp" will keep the same inode for the file.

Rod Hills
There be dragons...
machoq1
Esteemed Contributor

Re: hard link file , conceptual question

Thanks !
machoq1
Esteemed Contributor

Re: hard link file , conceptual question

cp does not modify inode number !