Is there an easy way to replace all symbolic links with the file they link to?
|
|
For some definitions of "easy":
|
|||
|
|
|
Might be easier to just use tar to copy the data to a new directory.
You could use something like this
typo: tar -hcf - sourcedir | tar -xf - -C newdir ^^^ tar --help: -H, --format=FORMAT create archive of the given format -h, --dereference follow symlinks; archive and dump the files they point to |
||||
|
|
"easy" will be a function of you, most likely. I'd probably write a script that uses the "find" command line utility to find symbolically linked files, then calls rm and cp to remove and replace the file. You'd probably do well to also have the action called by find check that there's enough free space left before moving the sym link too. Another solution may be to mount the file system in question through something that hides the sym links (like samba), then just copy everything out of that. But in many cases, something like that would introduce other problems. A more direct answer to your question is probably "yes". Edit: As per the request for more specific info. According to the man page for find, this command will list all sym link files in to a depth of 2 directories, from /:
To get find to execute something on finding it:
I believe that'll call some script I just made up, and pass in the file name you just found. Alternatively, you could capture the find output to file (use "find [blah] > symlinks.data", etc) then pass that file in to a script you've written to handle copying over the original gracefully. |
|||||||||||||
|
Will make a copy of each symlinked file/folder in |
|||
|
|
|
Lot's of good answers there but I since you were looking for something easy
|
||||
|
|
|
If i understood you correctly the Just copy all the symlinks and it will replace them with the files they point to. |
|||
|
|
|
I had the same problem with gwenview copying links when you would normally expect it to follow the link and copy the file. What I did to 'clean' the directory by following all the links and copying all the pointed-to files to the directory, was create a scratch directory, run e.g.
this is too dangerous to put in a script as there is no checking but it fixed my problem. |
|||
|
|