标签类目:find

Shell tar命令批量解压方法,排除指定目录及文件

分类:Shell第一种:

for tar in *.tar.gz;  do tar xvf $tar; done
for tar in *.tar.bz2; do tar xvf $tar; done

第二种:用tar命令批量解压某个文件夹下所有的tar.gz文件

ls *.tar.gz | xargs -n1 tar xzvf

第三种:

find -maxdepth 1 -name "*.bz2"|xargs -i tar xvjf {}

这条命令可解压当前目录下的所有bz2文件,maxdepth表示搜索深度,1代表只搜索当前目录

第四种:

for i in $(ls *.tar);do tar xvf $i;done

排除指定目录:

tar zcvf linuxany.tgz --exclude='*/log/*' linuxany/

排除指定文件:

tar zcvf linuxany.tgz --exclude='*/*.log*' linuxany/

linux find命令-exec参数的使用说明

说明:find命令,配合-exec参数,可以对查询的文件进行进一步的操作,可以得到很多有用的功能,比如说文件包含特定字符串的查询等,要了解这个功能,最简单直接的就是看find命令帮助,列出

        -exec command ;
               Execute command; true if 0 status is returned.   All   following   arguments   to find are taken to be arguments to the command until an   argument   consisting of #;’ is encountered.   The string {}’ is replaced by the current file name being processed everywhere it occurs in the arguments to the command, not just in arguments where it is alone, as in some versions of find.   Both of these constructions might need to be escaped (with a \’) or quoted to   protect   them   from   expansion   by the shell.   The command is executed in the starting directory. 继续阅读 »

find 的使用简单汇总

1. 按照名字找
find /home -name “*.*” -print
-name的文件命名规则可参考正则表达式

2.按照类型找
find /home -type f  -print
-type 常用值:f,文件类型;d,目录类型;l 链接类型 继续阅读 »


返回顶部