obscure Unix find command syntax understanding

落爺英雄遲暮 提交于 2019-12-23 05:16:22

问题


Need help in understanding this complex Unix find command and its operation:

find . \( \! -user xx -exec chown -- xx '{}' + -false \) -o    \
\( \! -group root -exec chgrp -- root '{}' + \) -o \
\( ! -perm 700 -exec chmod -- 700 '{}' + -exec false \; \)

Also, I am looking out in particular the purpose of -false predicate. I guess I mixed both GNU and non-GNU find syntax


回答1:


The false predicate evaluated to false for -o and it is used here to prevent short short-circuiting.

  • if user is not xx make it xx
  • if group is not root, make it root
  • if not all permissions are set for the owner, grant all permissions.

Each command is separated by -o and terminated by false so that they are ALL applied to each item.



来源:https://stackoverflow.com/questions/21525727/obscure-unix-find-command-syntax-understanding

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!