unix shell ksh: if statement won't execute both parts [closed]
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
开发者_C百科 Improve this questionguys, my if statement is just executing the 1st part, the else is never executed, even if trying with nonexistent files, files with no reading access. it's so sad, I have been trying but nothing. Would anyone suggest a trial for me please, Thanks.
#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
#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
精彩评论