bash 如何使用前缀目录tar
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5139753/
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-09-17 23:32:17 来源:igfitidea点击:
how to tar with a prefix directory
提问by Jas
I want to tar the directory /opt/mydir into a directory /opt/myprefix/mydir
我想将目录 /opt/mydir tar 到目录 /opt/myprefix/mydir
how can I do that with tar command? (solaris)
我怎么能用 tar 命令做到这一点?(索拉瑞斯)
thanks
谢谢
采纳答案by dogbane
Create a symlink so that you can access /opt/mydir as /opt/myprefix/mydir
创建一个符号链接,以便您可以将 /opt/mydir 作为 /opt/myprefix/mydir 访问
cd /opt
ln -s . myprefix
Then tar it:
然后tar它:
tar -cvf mytar.tar /opt/myprefix/mydir

