如何排除焦油绝对路径? [英] How do I exclude absolute paths for Tar?

查看:95
本文介绍了如何排除焦油绝对路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行一个PHP脚本,让我我想焦油的文件的绝对路径。这是语法我有:

I am running a PHP script that gets me the absolute paths of files I want to tar up. This is the syntax I have:

tar -cf tarname.tar -C /www/path/path/file1.txt /www/path/path2/path3/file2.xls

当我解压它创建的文件的绝对路径。我如何得到公正 /路径下的一切展现?

when I untar it create the absolute path to the files. How do I get just /path with everything under it to show?

推荐答案

如果您要删除的前n文件名的领先组件,需要带组件 。所以你的情况,对提取,执行

If you want to remove the first n leading components of the file name, you need strip-components. So in your case, on extraction, do

tar xvf tarname.tar --strip-components=2

借助手册页焦油<列表/ code>的许多选项,包括这一项。一些早期版本的焦油使用 - 条路径此操作,而不是

这篇关于如何排除焦油绝对路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆