tar 删除单个文件

不用解包,删除tar包中单个文件
tar –delete -f xxx.tar file
其中file如果在某个目录下,写全路径。例子如下:

[root@localhost named]# ls -l
total 1652412
drwxr-xr-x  5 named named      4096 Apr 30  2009 chroot
-rw-r--r--  1 root  root  911411200 Sep  2 21:57 name-20100902.tar
-rw-r--r--  1 root  root  778987520 Nov  4  2009 name.tar
[root@localhost named]# tar -tlv name-20100902.tar 

[root@localhost named]# tar -tlvf name-20100902.tar
drwxr-xr-x named/named       0 2009-04-30 12:36:56 chroot/
-rwxrwxrwx named/named      24 2008-10-07 13:52:46 chroot/.bash_logout
drwxrwxrwx named/named       0 2008-10-07 14:06:42 chroot/dev/
crw-r--r-- named/named     1,5 2008-10-05 14:28:20 chroot/dev/zero
crw-r--r-- named/named     1,8 2008-10-05 22:28:18 chroot/dev/random
-rwxrwxrwx named/named     124 2008-10-07 13:52:46 chroot/.bashrc
drwxrwxrwx named/named       0 2009-05-25 11:02:41 chroot/var/
d------rwx named/named       0 2010-09-02 21:50:49 chroot/var/run/
drwxrwxrwx named/named       0 2009-05-25 11:02:55 chroot/var/log/
-rw-rw-rw- named/named 911353183 2010-09-02 21:50:37 chroot/var/log/query.log

[root@localhost named]# tar --delete -f name-20100902.tar query.log
tar: query.log: Not found in archive
tar: Error exit delayed from previous errors
[root@localhost named]# tar --delete -f name-20100902.tar chroot/var/log/query.log
[root@localhost named]# ls -lh
total 744M
drwxr-xr-x  5 named named 4.0K Apr 30  2009 chroot
-rw-r--r--  1 root  root   50K Sep  2 21:58 name-20100902.tar
-rw-r--r--  1 root  root  743M Nov  4  2009 name.tar

请选择你看完该文章的感受:

不错 超赞 无聊 扯淡 不解 路过

随机文章:

Tags:

发表评论