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

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

概述我用的时候 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 我用的时候

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的所有文件和子目录都是如此

总结

以上是内存溢出为你收集整理的linux – 如何正确使用修剪? -type d和-type f对修剪有不同的影响?全部内容,希望文章能够帮你解决linux – 如何正确使用修剪? -type d和-type f对修剪有不同的影响?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1018633.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存