加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 如何正确使用修剪? -type d和-type f对修剪有不同的影

发布时间:2020-12-13 23:05:00 所属栏目:Linux 来源:网络整理
导读:我用的时候 find . -type f -path ./source/script -prune -o -print; 我在“pruned”./ source / script目录中获取文件. ..../source/script./source/script/myapp02.4372d2ea3388.js./source/script/myapp02.js./source/script/myapp02.1798d7bc34d2.js...
我用的时候

find . -type f -path ./source/script -prune -o -print;

我在“pruned”./ source / script目录中获取文件.

...
./source/script
./source/script/myapp02.4372d2ea3388.js
./source/script/myapp02.js
./source/script/myapp02.1798d7bc34d2.js
...

但是当我使用时:

find . -path ./source/script -prune -o -type f -print;

“pruned”目录中的文件被省略:

./generate.py
./readme.txt
./source/class/myapp02/Application.js
./source/class/myapp02/Application.js:75:      
./source/class/myapp02/__init__.js
./source/class/myapp02/Application.js~
./source/class/myapp02/theme/Font.js
./source/class/myapp02/theme/Theme.js
./source/class/myapp02/theme/Decoration.js
./source/class/myapp02/theme/Color.js
./source/class/myapp02/theme/Appearance.js
./source/class/myapp02/simulation/DemoSimulation.js
./source/class/myapp02/test/DemoTest.js
./source/translation/readme.txt
./source/index.html
./source/index.html~
./source/resource/myapp02/test.png
./Manifest.json
./config.json

在another example我看到:

find . -type d ( -path dir1 -o -path dir2 -o -path dir3 ) -prune -o -print

我看到的唯一区别是-type d在我的代码类型f中.

这是为什么-prune被忽略而且find程序在“pruned”目录中搜索的唯一原因?

解决方法

find . -type f -path ./source/script -prune -o -print;

被解释为

find . (-type f AND -path ./source/script AND -prune) OR (-print);
find . -path ./source/script -prune -o -type f -print;

被解释为

find . (-path ./source/script AND -prune) OR (-type f AND -print);

请注意,-print和-prune是评估为true的表达式.

因此,如果(-path ./source/script AND -prune)为true,则不计算(-type f AND -print)并且不调用-print.并且`(-path ./source/script AND -prune)对于./source/script的所有文件和子目录都是如此

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读