Shell脚本中的嵌套If语句 [英] Nested-If statements in Shell-scripting
本文介绍了Shell脚本中的嵌套If语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的脚本:
echo "Name"
read name
if [ "$name" == "abcd" ]; then
echo "Password"
read password
if [ "$password == "pwd" ]; then
echo "Hello"
else
echo "Wrong password"
fi
else
echo "wrong username"
fi
这是我运行它时得到的输出:
And this is the output I get when I run it:
sh hello.sh
Name
abcd
hello.sh: line 14: unexpected EOF while looking for matching `"'
hello.sh: line 16: syntax error: unexpected end of file
有什么主意吗?这可能是很愚蠢的,但是我花了将近一个小时.
Any idea whats wrong here? This could be a very silly one, but i wasted almost an hour on it.
推荐答案
if [ "$password == "pwd" ]; then
在$password
这篇关于Shell脚本中的嵌套If语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文