find . -not ( -path ./destdir -prune ) 中圆括号的作用和替代方法
在给定的命令 'find . -not ( -path ./destdir -prune )' 中,圆括号的作用是将 ' -path ./destdir -prune ' 作为一个整体,将其作为一个单元进行处理。
圆括号在这里的作用是创建一个逻辑组,它告诉 'find' 命令将 ' -path ./destdir -prune ' 看作一个单个条件。如果省略圆括号,命令将会按照默认优先级处理 ' -path ./destdir ' 和 ' -prune ' 选项,可能会导致不正确的结果。
可以使用逻辑操作符 ' -and ' 或 ' -or ' 来替代圆括号的作用,如下所示:
-
使用 ' -and ' 替代圆括号:
find . -not -path ./destdir -and -not -prune -
使用 ' -or ' 替代圆括号:
find . -not -path ./destdir -or -not -prune
这两种方式都可以实现与原始命令相同的效果。
原文地址: https://www.cveoy.top/t/topic/b7hA 著作权归作者所有。请勿转载和采集!