[英]Looking for files NOT owned by a specific user
我希望递归查看目录以查找不属于特定用户的文件,但我不确定如何编写它。
The find(1) utility has primaries that can be negated ("reversed") using the "!" find(1) 实用程序具有可以使用“!”否定(“反转”)的原色。 operator.操作员。 On the prompt one must however escape the negation with a backslash as it is a shell metacharacter.然而,在提示时,必须用反斜杠转义否定,因为它是一个 shell 元字符。 Result:结果:
find . \! -user foo -print
Looking for files NOT owned by someone寻找不属于某人的文件
Others have answered the question "NOT owned by a particular user" in the body.其他人在正文中回答了“不属于特定用户”的问题。 Here's one that answers the titular question but has not been provided:这是回答名义问题但尚未提供的问题:
$ find / -nouser
You can use it like so:你可以像这样使用它:
$ sudo find /var/www -nouser -exec chown root:apache {} \;
And a related one:还有一个相关的:
$ find / -nogroup
-user
finds by user or user ID, and !
-user
通过用户或用户 ID 查找,并且!
inverts the predicate.反转谓词。 So, ! -user ...
所以, ! -user ...
! -user ...
. ! -user ...
你可以使用这个:
find <dir> ! -user <username>
Using z-shell (zsh) you can use使用 z-shell (zsh) 你可以使用
ls -laR *(^U)
or或者
ls -la **/*(^U)
to search for all files recursively not owned by you.递归搜索所有不属于您的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.