linux - 如果特定用户无法写入目录,则 Linux shell 脚本会检查目录
问题描述
我正在尝试制作一个 Linux shell 脚本,找到一个或多个特定用户(envadmin)不可写的director(y)ies。
我想我必须将这两个部分结合起来:
# Part 1 - this not complete right because I need if not true that the dir is not writeable and the owner is envadmin:
find -type d -maxdepth 1 ! -writable -user envadmin # I know, this is not working by '! - writable'
# Part 2 - at the if I should need part 1 I think:
for directory in *
do
if [ $directory -user envadmin ] ; then
if [ ! -w $directory ] ; then
echo "De directory: $directory is from envadmin but not writeable"
fi
fi
done
我已经尝试了更多,但我希望我已经正确地解释了我想要的,我希望有人能把我引向正确的方向。
解决方案
您实际上不需要任何复杂的脚本:
find -maxdepth 1 -type d -user eventadmin -and -not -writable
这应该会给你想要的输出。
推荐阅读
- kotlin - Kotlin generateSequence 不记得内部状态
- powerbi - 根据列中的值,为空单元格返回“1”或“2”
- git - PyCharm / git:“不是有效的对象名称”
- php - 使用 codeigniter 建立多语言网站
- ag-grid - 有没有办法在没有企业版的情况下对 ag-grid 中的行进行分组?
- node.js - AngularJS 测试 - 来自服务的承诺无法解决
- c# - 添加行时如何在特定的 SQL Server 表上创建订阅?
- oracle-apex - Oracle APEX 无法设置通过 javascript 设置的页面项的会话
- javascript - 放置在工具栏中时,我的输入字段没有被捕获
- javascript - 如何使用 Flow 在 JavaScript 中定义 Hex 类型?