Preserving number of links with 'cp'. ( preserve number of links )
How can I use 'cp' to copy a file and perserve the links # to it? Below, when the file is copied the '239' get's changed to a '1'. I want that '239' preserved on the destination file. How can I do this?
[root@myserver forums]# ll /usr/bin/file.txt -rwxr-xr-x 1 root root 77408 Apr 7 2004 file.txt [root@myserver forums]# ll file.txt -rwxr-xr-x 239 root root 74792 Apr 7 2004 file.txt [root@myserver forums]# Thanks, Devyn |
You'll need to either create another link to it or move it otherwise it defeats the purpose of a link.
|
If a file is copied, it's a separate copy. The only way for it to have the 239 links would be for you to create 238 links to it. What behavior are you looking for? Links pointing to two files?
|
Hi,
I simply want the copy to reflect all the attributes it had of the original. For example, if I use 'mv' on the file, everything is preserved including the number of links. Not so when I use 'cp'. So basically what I want is to have the same behavior in 'cp' as I do in 'mv'. Btw, what is the command to see all the files that are pointed to this file I want to copy? Thank You, Devyn |
... I'm looking ot have 'cp' or another command to shift all the links to the new copy in the process ... ( I realize that a link can't point to more then one file btw :) )
Thanks, Devyn |
To find the names linked to a file, do something like the following:
Code:
find / -inum `ls -i FILENAME | cut -d' ' -f1` If you want to shift the references to the file, why not do this: Code:
mv OLDFILE NEWFILE |
Hello,
I like this one liner: find / -inum `ls -i FILENAME | cut -d' ' -f1` though it might take a while on a 95% full 300GB drive. I resolved the matter by unlinking. The reverse is also easy to implement. :) Thanks Again Guy's. You've been great help. Best Regards, Devyn |
No problem. Always glad to help.
|
All times are GMT -5. The time now is 11:03 PM. |