免费注册 查看新帖 |

Chinaunix

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

[学习分享] 根据配置文件从tgz/tar.gz中解压指定文件 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-05-08 08:14 |只看该作者 |倒序浏览
本帖最后由 sakulagi 于 2013-05-08 08:17 编辑

回复功能一直有问题。开个帖子贴一下吧:

  1. root@Deb606:~/test2# for i in 1 2 3 4 5; do touch file$i; done;
  2. root@Deb606:~/test2# ls
  3. file1  file2  file3  file4  file5
  4. root@Deb606:~/test2# tar czvf f.tgz file*
  5. file1
  6. file2
  7. file3
  8. file4
  9. file5
  10. root@Deb606:~/test2# ls
  11. file1  file2  file3  file4  file5  f.tgz
  12. root@Deb606:~/test2# rm -f file*
  13. root@Deb606:~/test2# ls
  14. f.tgz
  15. root@Deb606:~/test2# echo file2 >> extraction_candidates
  16. root@Deb606:~/test2# echo file5 >> extraction_candidates
  17. root@Deb606:~/test2# cat extraction_candidates
  18. file2
  19. file5
  20. root@Deb606:~/test2# ls
  21. extraction_candidates  f.tgz
  22. root@Deb606:~/test2# tar xzvf f.tgz `cat extraction_candidates`
  23. file2
  24. file5
  25. root@Deb606:~/test2# ls
  26. extraction_candidates  file2  file5  f.tgz
  27. root@Deb606:~/test2# rm file*
  28. root@Deb606:~/test2# for f in `cat extraction_candidates`; do tar xzvf f.tgz $f;done
  29. file2
  30. file5
  31. root@Deb606:~/test2# ls
  32. extraction_candidates  file2  file5  f.tgz
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP