Linux 如何压缩符号链接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5076181/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 02:58:16  来源:igfitidea点击:

how to compress a symbolic link?

linuxcommand-linetar

提问by krifur

i try to compress with tar a repertory in a chroot environment with ssh, but it failed as it just compress the symbolic link itself, how can I compress it's content ?

我尝试在 chroot 环境中使用 ssh 用 tar 压缩一个曲目,但它失败了,因为它只是压缩符号链接本身,我该如何压缩它的内容?

-bash-3.00$ ls -ail
1263583 lrwxrwxrwx  1 root     root       18 Apr 18  2008 mainwebsite_html -> ../../var/www/html

-bash-3.00$ tar -cjvf archive.tar.bz2 mainwebsite_html

-bash-3.00$ ls -ail
7509101 -rw-r--r--  1 user1 user1  136 Feb 22 08:57 archive.tar.bz2
1263583 lrwxrwxrwx  1 root     root       18 Apr 18  2008 mainwebsite_html -> ../../var/www/html

Thx

谢谢

采纳答案by Ignacio Vazquez-Abrams

From the tar(1)man page:

tar(1)手册页:

  -h, --dereference
          follow symlinks; archive and dump the files they point to
  -h, --dereference
          follow symlinks; archive and dump the files they point to

回答by Marcos Labad

Take care of placing the "h" option in the correct place. In your example:

注意将“h”选项放在正确的位置。在你的例子中:

tar -cjvf archive.tar.bz2 mainwebsite_html

should be

应该

tar -chjvf archive.tar.bz2 mainwebsite_html