Note:Overwriting of the symlinks occurs from tar version 1.27 or higher
Below I am trying to show what exactly the problem is.
contents of the dirtmp1
file1.txt
file2.txt
code to create the above directory
rm -f -r dirtmp1 && mkdir dirtmp1 && cd dirtmp1 && touch file1.txt && touch file2.txt && ls -al
creating a symbolic link
cd ..
ln -s dirtmp1/ symlink1
now create the tar file which contains the name as symlink1
mkdir dirtmp1
cd dirtmp1
mkdir symlink1 && cd symlink1 && touch iNeedThisfile.txt && cd .. && tar -cvzf symlink1.tar.gz symlink1/
Extract the tar file in folder(symlnk1) is overwriting the symbolic link. All I want is preserve the symbolic link and copy the "iNeedThisfile.txt"
After running this command tar -xvf symlink1.tar.gz
symlink1:
total 0
-rw-r--r-- 1 root root 0 Mar 24 18:14 iNeedThisfile.txt
Any flags while extracting which preserves the symbolic links while extracting. and copies the files to the folder pointed by the symbolic link.
I apologise for not able to convey my message in fewer lines of text.
tar -xvf {symlink1.tar.gz} {path/to/file}
– Condition-k
flag to tar change anything? (I can try this on a CentOS 7 machine later.) – Luedtke