Linux系统shell脚本基础之case判断语句
Posted 江湖有缘
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux系统shell脚本基础之case判断语句相关的知识,希望对你有一定的参考价值。
Linux系统shell脚本基础之case判断语句
一、脚本要求
1.用户输入三个one,two,three后,输出对应的语句
2.用户输入非以上三个,输出提示,请输入one,two,three
二、脚本要求
[root@192 scripts]# cat ./case.sh
#!/bin/bash
########################################
#Author:jeven
#time:Sat 21 May 2022 11:36:55 AM CST
#filename:case.sh
#Script description:
########################################
read -p "please input your choice:" CHOICE
case "$CHOICE" in
"one")
echo "Your choice is ONE"
;;
"two")
echo "Your choice is TWO"
;;
"three")
echo "Your choice is THREE"
;;
*)
echo "Usage $0 one|two|three"
;;
esac
三、执行脚本
root@192 scripts]# ./case.sh
please input your choice:one
Your choice is ONE
[root@192 scripts]# ./case.sh
please input your choice:two
Your choice is TWO
[root@192 scripts]# ./case.sh
please input your choice:three
Your choice is THREE
[root@192 scripts]# ./case.sh
please input your choice:1a1a1a
Usage ./case.sh one|two|three
以上是关于Linux系统shell脚本基础之case判断语句的主要内容,如果未能解决你的问题,请参考以下文章