我需要tar这个目录-totar:
$ ls -l totar/
total 61388
292 -rw-r--r-- 1 wasext was 298867 Apr 13 16:44 application.2015-01-19.0.log
108 -rw-r--r-- 1 wasext was 109623 Apr 14 13:32 application.2015-01-20.0.log
788 -rw-r--r-- 1 wasext was 805468 Apr 14 13:32 application.2015-01-21.0.log
1080 -rw-r--r-- 1 wasext was 1104861 Apr 14 13:32 application.2015-01-22.0.log
2052 -rw-r--r-- 1 wasext was 2098782 Apr 14 13:32 application.2015-01-23.0.log
4 -rw-r--r-- 1 wasext was 455 Apr 14 13:32 application.2015-01-24.0.log
21076 -rw-r--r-- 1 wasext was 21581073 Apr 14 13:32 application.2015-01-26.0.log
9296 -rw-r--r-- 1 wasext was 9519026 Apr 14 13:32 application.2015-01-27.0.log
17912 -rw-r--r-- 1 wasext was 18341302 Apr 14 13:32 application.2015-01-28.0.log
8780 -rw-r--r-- 1 wasext was 8989019 Apr 14 13:32 application.2015-01-29.0.log
我创建了带有参数“ -C”的tarball文件:
$ tar cvf t.tar -C totar/*
tar: can't change directories to totar/application.2015-01-19.0.log: Not a directory
a totar/application.2015-01-20.0.log 215 blocks
a totar/application.2015-01-21.0.log 1574 blocks
a totar/application.2015-01-22.0.log 2158 blocks
a totar/application.2015-01-23.0.log 4100 blocks
a totar/application.2015-01-24.0.log 1 blocks
a totar/application.2015-01-26.0.log 42151 blocks
a totar/application.2015-01-27.0.log 18592 blocks
a totar/application.2015-01-28.0.log 35823 blocks
a totar/application.2015-01-29.0.log 17557 blocks
我收到此错误:tar:无法将目录更改为totar / application.2015-01-19.0.log:不是目录
在创建的tar文件中缺少文件:totar / application.2015-01-19.0.log:
$ tar tf t.tar
totar/application.2015-01-20.0.log
totar/application.2015-01-21.0.log
totar/application.2015-01-22.0.log
totar/application.2015-01-23.0.log
totar/application.2015-01-24.0.log
totar/application.2015-01-26.0.log
totar/application.2015-01-27.0.log
totar/application.2015-01-28.0.log
totar/application.2015-01-29.0.log
在我犯错的地方可以帮我吗?
使用-C
选项tar
,您将被告知tar
要先将目录更改为该目录,然后再将文件添加到存档中。这非常方便,可以避免必须首先更改到该目录。假设您位于$HOME
目录中,并且想要将文件归档到中/path/to/totar
,则只需将-C
选项提供给上面的目录totar
和目标目录即可。如果要存档/path/to/totar
,则要:
tar -C /path/to cvf somearchive.tar totar
请注意,上面的文件规范totar
是目录名而不是文件名,并将包括目录中的所有文件totar
。您不包括通配符,但是可以包括特定的文件名。要仅备份以下文件/path/to/totar
:
tar -C /path/to/totar cvf somearchive.tar filename
到仅filename
在totar
目录中。(不允许使用通配符)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句