linux - 如何压缩符号链接(symbolic link)?

标签 linux command-line tar

使用 tar,我尝试使用 ssh 在 chroot 环境中压缩存储库,但失败了,因为它只是压缩了符号链接(symbolic link)本身。

如何压缩其内容?

-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

最佳答案

来自 tar(1) 手册页:

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

关于linux - 如何压缩符号链接(symbolic link)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5076181/

相关文章:

linux - 读取csv并写入excel格式

c++ - 如果我不给它提供命令行参数,为什么我的程序会崩溃?

python - 如何将用户输入转换为函数参数?

bash - tar:使用 -X 时从成员名称中删除前导/(排除文件)

shell - 在 Grunt 上压缩为 tar.gz

linux - tar 存档包含的文件少于 find 命令的结果

linux - gnu 发现异常 : filename wildcards broken?

linux - 如何递归更改文件名的大小写?

php - 在 Apache2 上运行 Python 脚本时,出现此错误 : IOError: [Errno 13] Permission denied

mysql - 从 cli 使用 mysql 时没有系统命令