Hello all The manual page of find says the following for the -prune action:
-prune True; if the file is a directory, do not descend into it. If -depth is given, false; no effect. Because -delete implies -depth, you cannot usefully use -prune and -delete together. So I understand that if -depth is given then -prune behaves as follows: a) returns false b) it has no effect. The point b) is clear but I think that the documentation is not correct for the returned value (point a)). See the example below. ----- BEGIN EXAMPLE ----- The following directory structure and the following statement show that -prune does not return false when -depth is given. mkdir -p test/s_files/ echo a-top > test/a-top.txt echo s-top > test/s-top.txt echo a > test/s_files/a.txt echo s1 > test/s_files/s1.txt echo s2 > test/s_files/s2.txt find ./test/ -depth \( -name s\* -a -prune -a -printf "printed with printf: %p\n" \) -o -exec bash -c 'echo printed with echo: {}' '; The result of this statement is: printed with printf: ./test/s_files/s1.txt printed with printf: ./test/s_files/s2.txt printed with echo: ./test/s_files/a.txt printed with printf: ./test/s_files printed with echo: ./test/a-top.txt printed with printf: ./test/s-top.txt printed with echo: ./test/ By reasoning step by step we have: 1) file ./test/s_files/s1.txt is found 2) find stars evaluating the expression; 3) -name s\* and returns true 4) if -prune returned false because of the presence of -depth then the result of the parenthesis \( -name s\* -a -prune -a -printf "printed with printf: %p\n" \) would be known (false) and -printf would not be executed. Instead -exec would have to be evaluated. ----- END EXAMPLE ----- I would add one more more thing: the documentation of -prune would be reformulated and explicitly specify that -prune returns true for "both files and folders". Best regards Cristian