免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5737 | 回复: 5
打印 上一主题 下一主题

[FreeBSD] 弱智问题:如何用tar只解压缩出tar.gz中的某一个文件夹 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-06-18 11:04 |只看该作者 |倒序浏览
rt

有一个xxx.tar.gz压缩包,如何用tar只解压缩某一个文件夹,谢谢

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
2 [报告]
发表于 2008-06-18 11:19 |只看该作者
tar cvf test.tar test
a test/ 0K
a test/abc/ 0K
a test/b 1K
a test/c 1K
a test/d 1K
a test/f 1K
a test/g 1K
a test/i 1K
a test/aa 1K
a test/bb 1K
a test/j 1K
a test/a1 1K
a test/123/ 0


gzip -d test.tar.gz|tar -xvf test.tar test/abc

abc 就是其中的一个目录

论坛徽章:
0
3 [报告]
发表于 2008-06-18 11:31 |只看该作者
执行完了,但貌似没反应:(

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
4 [报告]
发表于 2008-06-18 11:39 |只看该作者
test 是原压缩目录

你在试试吧 我已经测试过是好用的

论坛徽章:
0
5 [报告]
发表于 2008-06-18 12:10 |只看该作者
-t 选项列举包里的文件, 匹配模式和-x提取一样的
有两种匹配模式,一种是包含--include,一种是排斥--exclude, 至于-I/T, -X只是从文件中读取匹配模式



tar [bundled-flags <args>] [<file> | <pattern> ...]
     tar {-c} [options] [files | directories]
     tar {-r | -u} -f archive-file [options] [files | directories]
     tar {-t | -x} [options] [patterns]


     -t      List archive contents to stdout.
     -u      Like -r, but new entries are added only if they have a modifica-
             tion date newer than the corresponding entry in the archive.
             Note that this only works on uncompressed archives stored in reg-
             ular files.  The -f option is required.
     -x      Extract to disk from the archive.        If a file with the same name
             appears more than once in the archive, each copy will be
             extracted, with later copies overwriting (replacing) earlier
             copies.

     --exclude pattern (-W exclude=pattern)
             Do not process files or directories that match the specified pat-
             tern.  Note that exclusions take precedence over patterns or
             filenames specified on the command line.

     -f file
             Read the archive from or write the archive to the specified file.
             The filename can be - for standard input or standard output.  If
             not specified, the default tape device will be used.  (On
             FreeBSD, the default tape device is /dev/sa0.)

     -T filename
             In x or t mode, tar will read the list of names to be extracted
             from filename.  In c mode, tar will read names to be archived
             from filename.  The special name ``-C'' on a line by itself will
             cause the current directory to be changed to the directory speci-
             fied on the following line.  Names are terminated by newlines
             unless --null is specified.  Note that --null also disables the
             special handling of lines containing ``-C''.


     -X filename
             Read a list of exclusion patterns from the specified file.  See
             --exclude for more information about the handling of exclusions.

[ 本帖最后由 angeljyt 于 2008-6-18 12:39 编辑 ]

论坛徽章:
0
6 [报告]
发表于 2008-06-18 12:39 |只看该作者
tar cvf test.tar test
a test/ 0K
a test/abc/ 0K
a test/b 1K
a test/c 1K
a test/d 1K
a test/f 1K
a test/g 1K
a test/i 1K
a test/aa 1K
a test/bb 1K
a test/j 1K
a test/a1 1K
a test/123/ 0

如果你要提取test/abc
tar -xvf test.tar --include=test/abc
提取除了test/abc之外的
tar -xvf test.tar --exlude=test/abc
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP