【发布时间】:2016-06-05 18:16:05
【问题描述】:
我正在尝试比较 2 个文件的权限,但似乎无法获得正确的结果。谁能帮忙。
act= stat -c "%a" a
bac= stat -c "%a" b
echo "$act" # returns correctly eg 777, not sure if this is a string or no.
echo "$bac" # returns correctly as above
if [[ "$act"="$ghi" ]];
then
echo "Correct"
else
echo "Difference"
fi
这是我目前得到的 说属性是一样的 1.第一次a=777和b=777 2. 第二次a=222 and b=777
#!/bin/bash
active= stat -c "%a" a
backup= stat -c "%a" b
echo "$active"
echo "$backup"
if [[ "$active" = "$backup" ]];
then
echo "Properties are The Same"
else
echo "Properties are Different"
fi
这是我得到的输出
sandbox-computer work # ./compareFiles_02.sh
777
777
属性相同
sandbox-computer work # chmod 222 a
sandbox-computer work # ./compareFiles_02.sh
222
777
属性相同
【问题讨论】: