1
User=0
echo "Please select av ma ji im pr"
echo -n "First 2 initial of your Name eg: [av ma ji im pr]? "
read User
if [ $User = av ]
        then
                echo `$User`
elfi [ $User = ma ]
        then     # --> This line giving problem "syntax error near unexpected token `then'"
                echo `$User`
elfi [ $User = pr ]
        then
                echo `$User`
else
echo "ur name dsoes not exist"
fi
4

3 回答 3

0

有两个问题。第一个是elfi应该的elif

第二个是周围的反引号$user。他们应该被删除。如果变量包含空格,则应在变量周围使用双引号。

User=0
echo "Please select av ma ji im pr"
echo -n "First 2 initial of your Name eg: [av ma ji im pr]? "
read User
if [ "$User" = av ]
        then
                echo "$User"
elif [ "$User" = ma ]
        then
                echo $User
elif [ "$User" = pr ]
        then
                echo "$User"
else
echo "ur name dsoes not exist"
fi
于 2013-04-15T10:19:27.887 回答
0

elif你的陈述有错字。在 echo 语句中也不需要反引号。否则将导致执行 it as 命令,这不是您想要的。

User=0
echo "Please select av ma ji im pr"    
echo -n "First 2 initial of your Name eg: [av ma ji im pr]? "
read User
if [ $User = av ]
    then
            echo $User
elif [ $User = ma ]
    then
            echo $User
elif [ $User = pr ]
    then
            echo $User
else
echo "ur name dsoes not exist"
fi
于 2013-04-15T10:16:22.520 回答
0

请您下次尝试更好地格式化您的问题。

您的错误来自您的“else if”命令。

不是精灵,是 精灵

于 2013-04-15T10:17:37.443 回答