码迷,mamicode.com
首页 > 其他好文 > 详细

find tar 压缩第一层目录,用于资料备份。

时间:2015-04-23 12:59:51      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:

find *.tar.gz -exec tar zxvf ‘{}‘ \;
//查找当前目录下的.tar.gz 的文件的 并发送给后面的命令执行
find . -maxdepth 1
//查找当前目录下的文件并显示出来。
find . -maxdepth 1 -type d
//查找当前目录下的文件

find . -maxdepth 1 -type d -exec cp -r ‘{}‘ /home/android/autonavi-project/ ‘;‘
//查找当前目录 并拷贝到某个位置

find . -maxdepth 1 -type d -exec tar zcvf ‘{}‘.tar.gz ‘{}‘ ‘;‘
//对当前目录压缩后放到当前目录。
// -maxdepth 0表示先显示现在的目录再显示其他的。
find . -maxdepth 1 -type d -exec tar zcvf /test2/‘{}‘.tar.gz ‘{}‘ ‘;‘
//对当前目录压缩后放到指定(/test2/)。

find /test -path /test/a -prune -o -name "*" -print
//查找test目录下,显示除了a文件夹之外的文件


find /test2 -path /test2/a.tar.gz -prune -o -name "*" -print
//查找test2目录下的除了 a.tar.gz 的所有的文件和目录。

find /test2 -path /test2/..tar.gz -prune -o -name "*.tar.gz" -exec tar zxvf ‘{}‘ \;
//查找test2目录下的除了..tar.gz 的所有.tar.gz的进行解压。

find /test2 -path /test2/. -prune -o -name "*" -exec tar zcvf ‘{}‘.tar.gz ‘{}‘ \;
//查找test2目录下的除了.这个目录外的所有目录进行压缩。


//本文件的终极目标,一个目录下的目录进行压缩。不对当前目录进行压缩。并且不对OUT文件进行压缩。
find . -mindepth 1 -maxdepth 1 -path "./out" -prune -o -type d -exec tar zcvf ‘{}‘.tar.gz ‘{}‘ ‘;‘
//

find tar 压缩第一层目录,用于资料备份。

标签:

原文地址:http://www.cnblogs.com/ioio/p/4450014.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!