【发布时间】:2015-03-23 22:41:06
【问题描述】:
我尝试通过以下代码比较两个文件在 Bash 中的权限:
!#/bin/bash
echo "Enter the first file name: "
read first
echo "Enter the second file name: "
read second
fileperm=$(stat -c '%A' "$first")
filepermi=$(stat -c '%A' "$second")
if [ "$fileperm" = "$filepermi" ]; then
echo $(stat -c '%A' "$fileperm")
fi
但如果出现以下错误,它会给我错误:
stat: 无效选项 -- 'r' 尝试 'stat --help' 了解更多信息。
【问题讨论】:
-
不应该是
#!/bin/bash?