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

Thank you.

link|improve this question

62% accept rate
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
Either cases are fine. Thank you. – michael May 4 '10 at 6:53
feedback

2 Answers

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.

link|improve this answer
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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