大家好,我需要找到嵌套最深的可写文件夹:
我写了这个命令:find。 -type d -printf '%d:%p\n' |排序-n |尾部-1
但是如何添加条件“此文件夹是否可写”?
最佳答案
尝试这样做:
find . -type d -writable -printf '%d:%p\n' | sort -n | tail -1
man find
说:
-writable
Matches files which are writable. This takes into account access control lists and other permissions artefacts which the -perm test ignores. This test makes use of the access(2) system call, and so can be fooled by NFS servers which do UID mapping (or root-squashing), since many systems implement access(2) in the client's kernel and so cannot make use of the UID mapping information held on the server.
这也适用于 dirs。
关于linux - 嵌套最深的可写文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14448704/