Linux系统下压缩文件时过滤指定的文件 |Linux系统压缩指定文件代码

时间:2023-03-10 02:29:20
Linux系统下压缩文件时过滤指定的文件 |Linux系统压缩指定文件代码

进入要压缩的目录:

[root@iZ25c748tjqZ wechat]# cd /alidata1/htdocs/wechat/

查看目录:

[root@iZ25c748tjqZ wechat]# ll

total 24

drwxr-xr-x 2 root root 4096 Feb 23  2016 cert

drwxr-xr-x 2 root root 4096 Feb 23  2016 doc

drwxr-xr-x 3 root root 4096 Feb 23  2016 example

-rw-r--r-- 1 root root 2727 Nov 13  2015 index.php

drwxr-xr-x 3 root root 4096 Dec  7 09:20 lib

drwxr-xr-x 2 root root 4096 Feb 23  2016 logs

[root@iZ25c748tjqZ wechat]#

压缩并过滤文件:

[root@iZ25c748tjqZ wechat]# tar -zcvf ./wechat.tar.gz ./* --exclude=lib/data --exclude=doc

原文地址:http://www.whosmall.com