开发者

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

开发者 https://www.devze.com 2023-02-26 07:24 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
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

精彩评论

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