• tar 的–exclude参数,实现不包括某些文件(转)


    最近有人问我tar压缩能不能不包含不想要的文件或者文件夹 
    压缩包很利于传送,备份等等。但比如大量的日志文件一般是不需要备份,或者需要分开备份。 
    tar参数中的–exclude,这个是我在看鸟哥私房菜时看到的。当时觉得肯定有用,就多留意了几眼,但使用的时候发现不是那么回事,所以后来就多研究了一下。没想到现在对于备份来说很舒服~~~得心应手,如果要包含其他路径的文件需要使用–include 
    例子: 
    在我的test文件夹下面,包含一些symbian的sisx安装包及andoid包apk安装包等等 
    test的大致目录结构:

    [root@**** html]# tree -L 2 test
    test
    |--AndroidPad_v1.0.0_20111116_online_unsigned_1.apk
    ::|--KingGoo.Com.sh
    |-- PACK_NAME.apk
    |-- android.php
    |-- androidpad.php
    |-- bak
    |`-- Vancl_2.0.0.0000_14_20120117_online_unsigned_versionCode_20.apk
    |-- debug
    |-- head.php
    |-- index.php
    |-- index1.php
    |-- lingxin
    |-- make.php
    |-- make.sh
    |-- make.sh.bk
    |-- package.jar
    |-- s60V3_1.2.1_2011-08-22-1755_online_signed.sis
    ::
    |-- source_id.txt
    |-- symbian.php
    |-- temp
    |   |-- AndroidPhone_v1.3.2_demo_unsign_versionCode7.apk_android
    |   |-- KingGoo.Com_Err.log
    |   |-- android
    |   |-- androidpad
    |   |-- make.log
    |   |-- symbian
    |   `-- temp
    `-- test.php
    
    8 directories, 86 files

    我不想要*.sis、*.sisx、*.apk则:

    [root@**** html]# tar -czvf  test.tar.gz  test --exclude=test/*.sisx  --exclude=test/*.apk --exclude=test/temp/* --exclude=test/*.sis
    test/
    test/temp/
    test/make.sh
    test/package.jar
    test/android.php
    test/head.php
    test/test.php
    test/make.sh.bk
    test/make.php
    test/source_id.txt
    test/index.php
    test/index.php.bkkkk
    test/KingGoo.Com.sh
    test/bak/
    test/index.php.bk
    test/symbian.php
    test/debug/
    test/index.php.bkk
    test/index1.php
    test/index.php.bkkk
    test/androidpad.php
    test/lingxa

    查看一下,压缩包内的文件(非解压)

    [root@**** html]# tar  -tf  test.tar.gz 
    test/
    test/temp/
    test/make.sh
    test/package.jar
    test/android.php
    test/head.php
    test/test.php
    test/make.sh.bk
    test/make.php
    test/source_id.txt
    test/index.php
    test/index.php.bkkkk
    test/KingGoo.Com.sh
    test/bak/
    test/index.php.bk
    test/symbian.php
    test/debug/
    test/index.php.bkk
    test/index1.php
    test/index.php.bkkk
    test/androidpad.php
    test/lingxa

    版权声明:

    转载原创文章请注明,文章出处:http://kinggoo.com
    原文地址:http://kinggoo.com/linux-tarexlude.htm
  • 相关阅读:
    uip源码剖析【一】——【网络层】ARP解读
    MySql字符编码详解
    51单片机+uip实战
    dos中如何查找一个字符串是否包含在某个文件中,如果有则将该文件名输出
    Full TCP/IP for 8Bit Architectures 阅读
    个人PKM之路
    Overlooked Essentials For Optimizing Code
    Would it be faster to batch SetVertex/PixelShaderConstant calls?
    2D Skinned Mesh(3D的完全翻版 带旋转)
    The difference between d8&d9's constants def in asm shaders
  • 原文地址:https://www.cnblogs.com/xiangxiaodong/p/3573209.html
Copyright © 2020-2023  润新知