$7.49 .com domain with free InstantPage Website Builder$1.99 Web Hosting   捷飞网络官方淘宝店   Godaddy 优惠码
返回列表 发帖
分享到:




[应用&技术] 如何在Linux用tar归档压缩文件时忽略某些文件和目录的技巧

在Linux下,常用tar对文件或目录归档压缩,有时候需要忽略某些文件或目录,怎么做呢?
5 I  \* g; j) g5 U3 ?5 S原来,tar命令有个长参数 --exclude 可以用来指定排除掉的文件目录。[root@mos178 usr]# ls motixbin  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]# 1 d( t6 L! G6 b( _2 e4 I2 Q: R  U7 }
关键是要总结出要忽略文件的模式来。[root@sunrise root]# tar zcf work181.20130121a.tar.gz work181 --exclude log --exclude "*20*" --exclude bin                 [root@sunrise root]#
/ `# r/ h8 D- @9 Q与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, ~- o' A) U% G+ i0 F& t* b* ^
  • 源文【在Linux用tar归档压缩文件时忽略某些文件和目录】最新版,请访问:
    2 F" e2 P" u0 I2 C   http://www.vktone.com/articles/linux-tar-ignore-some-files.html
  • 更多关于【Linux命令】的文章,请访问:
    9 `2 r( }. P3 a( c   http://www.vktone.com/tags/linux_command.html
  • 更多关于【Linux】的文章,请访问:
    ' `( G  v' W4 [5 r( d   http://www.vktone.com/tags/linux.html
  • 更多关于【Linux】的文章,请访问:
    8 V) V- l( o& N5 l1 m1 i$ U' B" b1 r   http://www.vktone.com/linux.html

美国VPS、域名代购:http://tu8l.taobao.com

返回列表
Namecheap
Namecheap.com - Cheap domain name registration, renewal and transfers - Free SSL Certificates - Web Hosting
互联网安全