我有以下賣出代碼正確的輸出
#!/bin/sh
echo "hello"
echo "enter the salutation $abc"
read -r abc
if [ "$abc" = "1" ]
then
echo "Hiiii"
elif [ "$abc" = "2" ]
then
echo "haaaaa"
fi
echo "enter name $xyz"
read -r xyz
if
if [ "$xyz" = "1" ]
then
echo "Chris"
elif [ "$xyz" = "2" ]
then
echo "Morris"
fi
echo "you had put salutation as" "$abc"
echo "you entered name as " "$xyz"
我需要的最終印刷要像
you had put salutation as Hii
you entered name as chris
什麼,我得到的是
you had put salutation as 1
you entered name as 1
Any help? Do I need to mention the final statement inside the if elif statement?
那你當你進入提示f或'salutation'和'name'分別? –
@anthony我爲 –
輸入了1您的代碼不完整。它會拋出語法錯誤:'test.sh:第24行:語法錯誤:文件意外結束。不會產生你說你看到的輸出。 –