14

Can you please tell me how can I tar ball/compress a directory hierarchy with soft links in linux?

Thank you.

  • 1
    Do you want the final tarbal to have the soft-links or the target file of those links. It's unclear in your question. – slubman May 4 '10 at 6:51
9

GNU tar normally includes symlinks in the tarball it generates. If you want it to include the file the symlink points to instead then pass it -h/--dereference when creating the tarball.

| improve this answer | |
7

When used with standard arguments tar xvf the soft link are saved in the tar archive as soft-links. Then there is 2 cases

  • If your symlink is a full symlink, it might be broken when untarred.
  • If your symlink is a relative symlink, under the folder you are tarring it will work fine when extracted.

If you want to tar the file and not the symlink, you can use the -h / --dereference argument.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.