Pages

Showing posts with label tar. Show all posts
Showing posts with label tar. Show all posts

Wednesday, September 25, 2013

Tar following symlinks

Hi!

Suppose that we have to tar gzip a directory that contains two symlinks.

ROOT_DIRECTORY
     SYMLINK_A
     SYMLINK_B



SYMLINK_A
     FILE_A
     FILE_B

SYMLINK_B
     FILE_C
     FILE_D



If you use the usual command tar -zcvf ROOT_DIRECTORY.tgz ROOT_DIRECTORY

You will get an archive that contains two symbolic links.

ROOT_DIRECTORY
     SYMLINK_A
     SYMLINK_B



If you want to include the content of symbolic links, you need to add a "h" just after the "c",

The command is tar -zchvf ROOT_DIRECTORY.tgz ROOT_DIRECTORY

You will get the directory including all the files under the ROOT_DIRECTORY

ROOT_DIRECTORY
     SYMLINK_A
          FILE_A
          FILE_B

     SYMLINK_B
          FILE_C
          FILE_D