开发者

unix shell ksh: if statement won't execute both parts [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

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 question

guys, 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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜