find命令 查找包含样式的目录和文件, 默认查找当前目录以及子目录 跟-exec 后续执行命令

参数:
-name<范本样式>:指定字符串作为寻找文件或目录的范本样式
-iname<范本样式>:此参数的效果和指定“-name”参数类似,但忽略字符大小写的差别;
-exec<执行指令>:假设find指令的回传值为True,就执行该指令。-exec参数以分号;结尾。
  {} 花括号代表前面find查找出来的文件名
 -exec选项后面跟随着所要执行的命令或脚本,然后是一对儿{ },一个空格和一个\,最后是一个分号
如:
find . -type f -exec ls -l {} \; 
find .-type f -user root -exec chown tom {} \;
find . -type f -name "*.txt" -exec cat {} \;> all.txt

   因为单行命令中-exec参数中无法使用多个命令,以下方法可以实现在-exec之后接受多条命令

-exec ./text.sh {} \;
 

find ./ -size +1M -o -type d  #寻找当前目录下文件大于1M的文件或者是目录。
-a and
-o or
-not not
常跟上-exec 执行后续命令
如:


参考:http://blog.csdn.net/liuhuiyan_2014/article/details/45053919
http://man.linuxde.net/find
http://blog.csdn.net/u014762921/article/details/54287302

posted on 2018-01-25 23:51  BioinformaticsMaster  阅读(1519)  评论(0编辑  收藏  举报

导航