伙计们,我的if语句只执行第一部分,即使尝试使用不存在的文件,没有读取权限的文件,也不会执行else。它太伤心了,我一直在尝试,但没有。 有人会建议我试用,谢谢。
#testing file to be read and display error messages:
if [ -f "$file" ]
then
echo="Error: Nonexistent or irregular file. "
break
else
echo Found
fi
if [ -r "$file" ]
then
echo "No Reading access"
break
else
echo Reading Access
fi
答案 0 :(得分:0)
#testing file to be read and display error messages:
if [ -f "$file" ];then
echo "Error: Nonexistent or irregular file. "
else
echo Found
fi
if [ -r "$file" ];then
echo "No Reading access"
else
echo Reading Access
fi