zoukankan      html  css  js  c++  java
  • 在Linux用tar归档压缩文件时忽略某些文件和目录

    在Linux下,常用tar对文件或目录归档压缩,有时候需要忽略某些文件或目录,怎么做呢?

    原来,tar命令有个长参数 --exclude 可以用来指定排除掉的文件目录。

    [root@mos178 usr]# ls motix
    bin  bin.1153887679  bin.20080407zhy_something_wrong  cfg  cfg.1153887679  cfg.20070425.tar.gz  log  motix0405.tar.gz  run
    [root@mos178 usr]# tar zcf motix.20130121a.tar.gz motix --exclude log --exclude "*.gz"
    [root@mos178 usr]# tar ztvf motix.20130121a.tar.gz 
    ...
    [root@mos178 usr]# 
    
    

    关键是要总结出要忽略文件的模式来。

    [root@sunrise root]# tar zcf work181.20130121a.tar.gz work181 --exclude log --exclude "*20*" --exclude bin                 
    [root@sunrise root]# 
    
    

    与tar --exclude相关的参数说明如下:

           --exclude PATTERN
                  exclude files based upon PATTERN
    
           -X, --exclude-from FILE
                  exclude files listed in FILE
    
           --wildcards
                  use wildcards with --exclude
    
           --wildcards-match-slash
                  wildcards match slashes (/) with --exclude
    
           --no-anchored
                  match any subsequenceof the name’s components with --exclude
    
           --no-ignore-case
                  use case-sensitive matching with --exclude
    
           --no-wildcards
                  don’t use wildcards with --exclude
    
           --no-wildcards-match-slash
                  wildcards do not match slashes (/) with --exclude
    
    
    
  • 相关阅读:
    领料单取整
    财务应付金额对不上的
    销售订单计算交期
    辅助单位启用
    K3CLOUD日志目录
    QLIKVIEW-日期格式,数字格式写法
    MRP运算报错-清除预留
    整单折扣后 财务、暂估应付价税合计对不上的问题处理
    BZOJ 2976: [Poi2002]出圈游戏 Excrt+set
    BZOJ 3060: [Poi2012]Tour de Byteotia 并查集
  • 原文地址:https://www.cnblogs.com/bjanzhuo/p/3576117.html
Copyright © 2011-2022 走看看