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

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 '{}' ';'
//

posted @ 2015-04-23 11:45  johnny_shi  阅读(835)  评论(0编辑  收藏  举报