当前位置: 技术问答>linux和unix
linux脚本:判断用户输入,进行不同操作
来源: 互联网 发布时间:2016-07-18
本文导语: 比如实现举例 if (如果用户输入y或者Y) { …… } else { …… } | /oradata1/aiobstest/zzw>% cat shell.sh echo "please input you user name:" read username echo $username if [ $username = 'aiobstest' -o $user...
比如实现举例
if (如果用户输入y或者Y)
{
……
}
else
{
……
}
if (如果用户输入y或者Y)
{
……
}
else
{
……
}
|
/oradata1/aiobstest/zzw>% cat shell.sh
echo "please input you user name:"
read username
echo $username
if [ $username = 'aiobstest' -o $username = 'AIOBSTEST' ]
then
echo 'success'
else
echo 'failure'
fi
/oradata1/aiobstest/zzw>%
/oradata1/aiobstest/zzw>% sh shell.sh
please input you user name:
aiobstest
aiobstest
success
/oradata1/aiobstest/zzw>% sh shell.sh
please input you user name:
AIOBSTEST
AIOBSTEST
success
/oradata1/aiobstest/zzw>% sh shell.sh
please input you user name:
Aiobstest
Aiobstest
failure
echo "please input you user name:"
read username
echo $username
if [ $username = 'aiobstest' -o $username = 'AIOBSTEST' ]
then
echo 'success'
else
echo 'failure'
fi
/oradata1/aiobstest/zzw>%
/oradata1/aiobstest/zzw>% sh shell.sh
please input you user name:
aiobstest
aiobstest
success
/oradata1/aiobstest/zzw>% sh shell.sh
please input you user name:
AIOBSTEST
AIOBSTEST
success
/oradata1/aiobstest/zzw>% sh shell.sh
please input you user name:
Aiobstest
Aiobstest
failure