How do I dereference links when extracting from a tar file?
6,141
Mount the archive as a directory, for example with AVFS, then use your favorite file copying tool.
mountavfs
cp -RLp ~/.avfs$PWD/bob.tar\# target-directory/
Related videos on Youtube
Author by
Chance
Updated on September 18, 2022Comments
-
Chance almost 2 years
If I have a tar file,
bob.tar
, which containsreal_file
andlink_to_real_file
, in which the latter is a symlink, is there a way to extract the contents ofbob.tar
so thatlink_to_real_file
will not be a symlink, but be a copy ofreal_file
.I know this is indeed possible on the creation side, if I use the
-h
flag.The command
tar -cvhf bob.tar real_file link_to_real_file
will dereferencelink_to_real_file
, but I want to do this on the extraction side regardless of how the tar file was created.-
Gilles 'SO- stop being evil' over 8 yearsSee also a similar question about hard links.
-