在备份ltedecoder程序时,须要把此文件夹拷由到bak文件夹下。但decoder文件夹下有个大文件,不须要备份,还有日志问题,也不须要备份,怎样实现呢??

方法: 

   cd /source-dir

        find . -name .snapshot-prune-o-print0 | cpio -pmd0 /dest-dir

解释: This command copies the contents of /source-dir to /dest-dir, but omits files and directories  named  .snapshot (and  anything in them).  The construct-prune -o -print0 
is quite common. The idea here is  that  the  expression  before  -prune  matches  things  which  are  to be pruned.  However, the -prune action itself returns true, so the following -o  ensures that the right hand side is evaluated only for those directories
which didn't get pruned (the  contents  of the pruned directories are not even visited, so their contents are irrelevant).  The expression on the right  hand side of the -o is in parentheses only for clarity.  It emphasises that the -print0 action takes place
only for  things  that  didn't have -prune applied to them.  Because the default `and' condition between tests binds more tightly than -o, this is the default anyway, but the parentheses help to show what is going on.

此段的意思是:当找到name为.snapshot时,prune就会返回真。-o是或的意思,“或”的使用技巧是当左边的表达式为“真”时。则不会运算右边的表达式。当左边的表达式为假。则运算右边的表达式,即,当左边name不为.snapshot。则进行右边的表达式,右边的表达式意思是print文件名称(包含路径的);当找到name为.snapshot时,则不打印文件名称。这样就实现了把非.snampshot为命名的文件打印出来并交给cpio进行处理。cpio则把这些文件拷则的dest-dir中,实现忽略.snampshot文件的拷备(注:文件指目录或file名)。

拓展:

-prune -o ... -print0
“... -print0”

这里能够使用find的查找文件的參数。如-name,-size等。

find . -name Persistence -prune -o  ! -name '*log*'  ! -size +100M -print0   | cpio -pmd0 /root/do_bak/ltedecoder

上面则不仅忽略Persistence文件夹,还会忽略包涵log的文件或文件夹,还会忽略大于100M的文件。

注意: 你一定注意到了find 后面是“.”,代表当前文件夹,即此命令必须是pwd是你要拷则的文件夹里面,如你把sour-dir的文件进行拷则,则须要先cd $sour-dir。

怎样cp文件夹时忽略指定的文件夹和文件的更多相关文章

  1. git提交时忽略指定文件

    git提交时忽略指定文件 我们在项目开发过程中经常用到git来管理自己的项目,使用git版本控制进行多人协作开发具有许多优势,这里就不一一阐述了,有兴趣的同学可以自己去查找资料进行系统的学习.而本篇文 ...

  2. idea使用Git提交代码时忽略指定文件或文件夹

    简述 使用idea编写代码并使用git作为版本控制器的时候,常常不需要提交配置文件以及一些其他不需要提交的文件,可以使用.ignore插件来在上传的时候忽略一些文件或文件夹. 安装 注意:安装完成之后 ...

  3. TortoiseSVN 更新时忽略指定文件夹

    命令行可以这么来svn update –set-depth=exclude 文件夹 那么TortoiseSVN客户端呢?在文件夹右键中的”更新至版本(U)”更新深度选”排除”,确定,搞定下次更新就不会 ...

  4. svn更新时忽略指定文件或文件夹

    选择一个收SVN控制的文件夹->右击->选择TortoiseSVN->更新至版本,就会出现   选择更新深度为工作副本,再选择项目,出现如图中所示的界面,把不想更新的文件或者文件夹前 ...

  5. 让 SVN (TortoiseSVN)提交时忽略指定目录

    2013-06-23 更新 后来我使用属性来过滤,结果反而没有效果了,之后我再次尝试使用全局忽略样式设置:*/bin */obj */packages 结果又有效果了,奇怪了. ------- 由于我 ...

  6. laravel 修改时邮箱字段唯一性验证时忽略指定 ID

  7. git中 .ignore文件的配置 忽略不想上传的文件

    1.配置语法: 以斜杠“/”开头表示目录: 以星号“*”通配多个字符: 以问号“?”通配单个字符 以方括号“[]”包含单个字符的匹配列表: 以叹号“!”表示不忽略(跟踪)匹配到的文件或目录: 此外,g ...

  8. spl处理文件(文件详细信息、文件遍历、查询指定行、写入CSV文件)

    <?php /** * 文件操作 */ //常用操作 $file = new SplFileInfo('D:/workspace/xlyy/spl/test.txt'); $file_info ...

  9. java 提取(解压)rar文件中特定后缀的文件并保存到指定目录

    内容简介 本文主要介绍使用junrar来提取rar压缩文件中特定后缀(如:png,jpg)的文件并保存到指定目录下. 支持v4及以下版本压缩文件,不支持v5及以上. 在rar文件上右键,查看属性,在压 ...

随机推荐

  1. 项目: 基于Python socket模块实现的简单 ftp 项目:

    需要 自己创建一个 info 文件 用来存储用户信息 服务器: import socket import pickle import struct import os import time ''.s ...

  2. Linux系统下到哪儿寻找硬件错误

    Linux系统下到哪儿寻找硬件错误       当linux系统出现故障的时候,作为管理员首先要定位错误,现在linux有许多工具都能帮助用户寻找错误,要学会利用他们确定问题.这些工具包括dmesg. ...

  3. SQL 锁 lock

    http://www.cnblogs.com/huangxincheng/p/4292320.html 关于sql 中的锁. 1 排他锁 sql中在做 insert update delete 会存在 ...

  4. arping---发送arp请求到一个相邻主机

    arping命令是用于发送arp请求到一个相邻主机的工具,arping使用arp数据包,通过ping命令检查设备上的硬件地址.能够测试一个ip地址是否是在网络上已经被使用,并能够获取更多设备信息.功能 ...

  5. [Angular & Unit Testing] Testing a RouterOutlet component

    The way to test router componet needs a little bit setup, first we need to create a "router-stu ...

  6. NET Framework 4.5 有更加简便的方法 Task.Run()

    NET Framework 4.5 有更加简便的方法 Task.Run()

  7. Mybaits中session的应用一

    获取一级缓存session SqlSession session = this.yangchebaoDbManagerImpl.getSqlSessionFactory().openSession(f ...

  8. 有关 Lambda && linq练习 有待整理

    1. 查询Student表中的所有记录的Sname.Ssex和Class列.(select sname,ssex,class from student) Students.Select(s=> ...

  9. [Javascript AST] 2. Introduction: Write a simple ESLint rule

    What we want to do is checking if user write nested if statements which actually can combine to one: ...

  10. install-软件安装跟push的区别

    今天在做项目的时候,需要往一个user版本的手机中安装一个应用,就在网上查了相应的方法,可以使用如下命令 adb install -r out/target/product/vanzo6752_lwt ...