好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

linux中tar压缩时排除某些目录或文件 - linux教程

linux中tar压缩时排除某些目录或文件

linux中tar命令是Unix/Linux系统中备份文件的可靠方法,几乎可以工作于任何环境中,它的使用权限是所有用户了,下文我们要介绍的就是利用tar压缩时排除某些目录或文件简单例子,希望例子能帮助到各位.

在对某个目录进行压缩的时候,有时候想排除掉某个目录,示例如下,比如文件目录包含以下文件及目录,代码如下:

  • api 
  • api/addons 
  • api/connect 
  • api/connect/connect.php 
  • api/google 
  • api/remote 
  • api/remote/mod //phpfensi.com  

    我们要压缩不包含google文件夹、connect/connect.php以及remote下mod文件夹,代码如下:

    tar -zcvf mytest.tar.gz api --exclude=google --exclude=connect/connect.php  --exclude=remote/mod

    注意: 1、--exclude=file1 而不是 --exclude file1  

    2、要排除一个目录是--exclude=dir1而不是--exclude=dir1/

    查看更多关于linux中tar压缩时排除某些目录或文件 - linux教程的详细内容...

  •   阅读:78次