I am new bee for Linux. I have a question about the command find. When I search a file under a directory, I would like to skip a sub-directory named publishfind ./ -path ./publish -prune -o -iname rdesvc -type f -printIt works fine:./release/apps/rdeSvc/server/linux/rdeSvcBut, if I remove the parameter -print:find ./ -path ./publish -prune -o -iname rdesvc -type fIt will output the sub-directory name with the search result:./publish./release/apps/rdeSvc/server/linux/rdeSvcI feel confusion. Why the sub-directory name publish is outputted if I removed the parameter -print?My distribution is CentOS 6.6 64 bit.
A confusion about the parameter -print in the command find
find
This is a combination of find's default action being -print and find's operator precedence.find ./ -path ./publish -prune -o -iname rdesvc -type f -printis interpreted asfind ./ \( -path ./publish -prune \) -o \( -iname rdesvc -type f -print \)so ./publish is pruned, and anything matching rdesvc is printed.Butfind ./ -path ./publish -prune -o -iname rdesvc -type fis interpreted asfind ./ \( \( -path ./publish -prune \) -o \( -iname rdesvc -type f \) \) -printso ./publish is pruned and printed, and anything matching rdesvc is printed. (The -prune action evaluates to true.)