系统:ubuntu
版本:13.02 和 12.04
执行命令:tar -czf first_20130508.tar.gz -C /home/fyc/Documents/myTmp
或tar -czf first_20130508.tar.gz -C /home/fyc/Documents/myTmp/*
报错:
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information.
说明:
/home/fyc/Documents/myTmp目录下是有文件的,不明白怎么会报这个错。是因为打包的指定路径不用-C参数吗?
以上问题已解决,请看一下补充的问题
补充:
知道-C是解压缩时候的命令了。
还有一个问题
tar -cz**P**f first_20130508.tar.gz /home/fyc/Documents/myTmp/*
执行这个命令,会把绝对路径打到包里去,如果我想打相对路径,有什么参数吗? 也就是当使用
tar -tzf first_20130508.tar.gz
查看时,希望直接是/home/fyc/Documents/myTmp/目录下的文件名,而不带路径。
巴扎黑2017-04-17 11:26:42
-C in tar specifies the decompression path.
When packaging, directly add the path or file to be packaged after the package file name. According to the example you mentioned, the packaging command should be:
tar -czf first_20130508.tar /home/fyc/Documents/myTmp
That is to say, removing the -C should be enough.
==================
You can also specify the -C option when compressing, which is used to specify a relative path. In the example you mentioned, the tar command should be changed to: tar -czf first_20130508.tar.gz -C /home/fyc/Documents/ myTmp
PHPz2017-04-17 11:26:42
Packaging without path should be: cd /home/fyc/Documents/myTmp; tar zcf /This points to the path where tar.gz is stored/first_20130508.tar.gz *
黄舟2017-04-17 11:26:42
tar -zcvf external_libva.tgz -C external/libva .
You forgot the dot after it. -C is only responsible for switching directories, but it does not tell tar which files to add to the archive