rog*_*r34 1 permissions bash chmod
我需要一个脚本,它采用一个命令行参数作为目录路径.脚本应该检查参数以确定它是否实际上是一个目录.如果它是目录,则脚本应将位于其中的任何子目录的保护模式更改为600.如果参数不是目录,则应打印出相应的消息.
我有
如果[-d $ 1]; 然后
其他
echo"这不是目录"
科幻
基本上我不知道该把什么放在空白处.我用chmod搞砸了,但我的线似乎想改变输入的路径,而不仅仅是子目录.
if test -d "$1"; then
find "$1" -type d -exec chmod 600 '{}' \;
else
echo "Not a directory: $1" >&2
exit 1
fi
各种变体可能更快,但取决于古代find或xargs.
find "$1" -type d -exec chmod 600 '{}' +
find "$1" -type d -print0 | xargs -0r chmod 600
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
903 次 |
| 最近记录: |