2
带有通配符文件模式的tar -C
我可以使用tar命令更改目录并使用通配符文件模式吗? 这是我想做的事情: tar -cf example.tar -C /path/to/file *.xml 如果我不更改目录(-C),它会起作用,但是我试图避免tar文件中的绝对路径。 tar -cf example.tar /path/to/file/*.xml 这是我做过的一些其他尝试: tar -cf example.tar -C /path/to/file *.xml tar -cf example.tar -C /path/to/file/ *.xml tar -cf example.tar -C /path/to/file/ ./*.xml tar -cf example.tar -C /path/to/file "*.xml" 这是我得到的错误: tar: *.xml: Cannot stat: No such file or directory 我知道还有其他方法可以完成这项工作(使用find,xargs等),但是我希望仅使用tar命令来完成此任务。 有任何想法吗?