how to correctly use prune? -type d and -type f have a different effect on prune?

When I use

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

I get files in the "pruned" ./source/script directory.

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

But when I use:

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

the files in the "pruned" directory are omitted:

./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

In another example I see:

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

The only difference I see with mine is that the -type d is in my code -type f.

Is that the only reason why -prune is ignored and the find program searches inside the "pruned" directory?

Answers


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

is interpreted as

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

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

is interpretted as

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

Note that -print and -prune are expressions that evaluate to true.

So if (-path ./source/script AND -prune) is true then (-type f AND -print) is not evaluated and -print is not called. And `(-path ./source/script AND -prune) is true for all the files and subdirectories of ./source/script


Need Your Help

Why is the request body empty when trying to call SOAP webservice with jQuery AJAX?

jquery ajax web-services soap

I have constructed a full soap envelope soapEnvelopeXML and I can see the call come through my TCP/IP Monitor, but the issue is that instead of calling the right method, the request URI comes in

How to use FlashControl (MediaCapture.VideoDeviceController)

c# .net wpf windows windows-8

I'm trying to use the Windows 8 Camera API to take picture with flash on a desktop app to use on a Windows 8.1 tablet.