tar:如何捆绑“解压到目录 XXX";tar 文件中的信息

编程入门 行业动态 更新时间:2024-10-18 02:39:48
本文介绍了tar:如何捆绑“解压到目录 XXX";tar 文件中的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我知道 'tar xf -C DIR' 会解压 DIR 中的文件,但是当我创建 tar 文件时,是否有一个选项可以将-C DIR"信息捆绑在 tarball 中,以便当我使用 'tarxf'文件会自动解压到DIR吗?

I know 'tar xf -C DIR' will untar the files in DIR, but is there an option to bundle the "-C DIR" information within the tarball when I create the tar file, so that when I use 'tar xf' the files will be automatically extracted into DIR?

谢谢.

推荐答案

创建 DIR,然后将文件符号链接到 DIR(不涉及复制),然后使用带有取消引用 (-h) 的 GNU tar选项:

Create DIR, then symlink the files into DIR (no copying involved), then use GNU tar with the dereference (-h) option:

mkdir DIR
ln -s /path/to/f1 /path2/f2 DIR/
tar chf archive.tar DIR
rm -rf DIR

这将存档符号链接指向的实际文件(而不是您临时创建的符号链接)

This will archive the actual files pointed by the symlinks (and not the symlinks you created temporarily)

缺点是你不能把实际的符号链接放在存档中,当然(它们也会被取消引用)

Downside is you can't put actual symlinks in the archive, of course (they too will be dereferenced)

这篇关于tar:如何捆绑“解压到目录 XXX";tar 文件中的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 10:05:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1407736.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   目录   信息   tar   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!