对find参数-prune的理解
2015-08-27 15:04
246 查看
find . ! -name "." -type d -prune -o -type f -iname "*.zip" -print
-path "/usr/sam" -prune -o -print 是 -path "/usr/sam" -a -prune -o -print 的简写表达式按顺序求值, -a 和 -o 都是短路求值,与 shell 的 && 和 || 类似如果 -path "/usr/sam" 为真,则求值 -prune , -prune 返回真,与逻辑表达式为真;否则不求值 -prune,与逻辑表达式为假。如果 -path "/usr/sam" -a -prune 为假,则求值 -print ,-print返回真,或逻辑表达式为真;否则不求值
-print,或逻辑表达式为真。
这个表达式组合特例可以用伪码写为
理解:-prune前面的判定条件为真时,会结束当前文件的判定过程并且当它为目录时,会阻断对其中的文件及子目录的遍历。
当find命令末尾没有-print时,默认的-print是绑定整个find命令的,所以会有输出,而显式的-print是绑定-prune之后的判定条件的,当-prune之前的条件通过时不会有输出
版权声明:本文为博主原创文章,未经博主允许不得转载。
-path "/usr/sam" -prune -o -print 是 -path "/usr/sam" -a -prune -o -print 的简写表达式按顺序求值, -a 和 -o 都是短路求值,与 shell 的 && 和 || 类似如果 -path "/usr/sam" 为真,则求值 -prune , -prune 返回真,与逻辑表达式为真;否则不求值 -prune,与逻辑表达式为假。如果 -path "/usr/sam" -a -prune 为假,则求值 -print ,-print返回真,或逻辑表达式为真;否则不求值
-print,或逻辑表达式为真。
这个表达式组合特例可以用伪码写为
if -path "/usr/sam" then -prune else -print
理解:-prune前面的判定条件为真时,会结束当前文件的判定过程并且当它为目录时,会阻断对其中的文件及子目录的遍历。
当find命令末尾没有-print时,默认的-print是绑定整个find命令的,所以会有输出,而显式的-print是绑定-prune之后的判定条件的,当-prune之前的条件通过时不会有输出
版权声明:本文为博主原创文章,未经博主允许不得转载。
相关文章推荐
- django学习笔记
- 如何将RobotFramework中case的执行结果上传到TestLink中。
- linux压缩文件——解压方法
- apache功能配置
- Js解析xml文件并简单实现省市区级联菜单(并解决各浏览器兼容性问题).
- HDU 1248 漫步校园 (优先队列+BFS求最短路+记忆化搜索)
- linux LCD驱动(二)--FrameBuffer
- XML数据生成和解析
- jQuery网格插件 ParamQuery Grid
- 彻底搞明白layout_weight
- centos上libreoffice+unoconv安装步骤,实现word转pdf
- Core Data 数据持久化存储
- linux系统——线程
- 字符串操作的实现:strstr、strcat、strcmp和stcpy
- org.apache.hadoop中遇到的API记录
- hdoj 5344 找规律
- eclipse SVN 插件安装
- Unity2d 弱联网游戏制作(二) 动画、场景、渲染层、碰撞检测、音乐播放
- dwr简单推送的例子
- 贝尔(Bell)数