linux系统中case命令⽤法1、case命令选择执⾏
[root@linuxprobe test]# ls
test.sh
[root@linuxprobe test]# cat test.sh ## 查看脚本
#!/bin/bash
echo "This is a test!"
echo "you can choose 0-9 or a-z or other!!"
read -p "please input what you want to do:" INPUT
case $INPUT in
[0-9])
touch {0..9}.txt
;
;
[a-z])
mkdir {a..z}.dir
;;
*)
echo "nothing to do!"
esac
[root@linuxprobe test]# bash test.sh
This is a test!
you can choose 0-9 or a-z or other!!
please input what you want to do:9 ## 执⾏匹配数字的情况
[root@linuxprobe test]# ls
< 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt test.sh
[root@linuxprobe test]# bash test.sh
This is a test!
you can choose 0-9 or a-z or other!!
linux登录命令please input what you want to do:s ## 执⾏匹配字母的情况
[root@linuxprobe test]# ls
< 3.txt 6.txt 9.txt c.dir f.dir i.dir l.dir o.dir r.dir test.sh w.dir z.dir
< 4.txt 7.txt a.dir d.dir g.dir j.dir m.dir p.dir s.dir u.dir x.dir
< 5.txt 8.txt b.dir e.dir h.dir k.dir n.dir q.dir t.dir v.dir y.dir
[root@linuxprobe test]# bash test.sh
This is a test!
you can choose 0-9 or a-z or other!! ## 执⾏匹配其他(*)的情况
please input what you want to do:
nothing to do!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论