位置: 编程技术 - 正文

shell脚本中case条件控制语句的一个bug分析(linux脚本case)

编辑:rootadmin

在shell脚本中,发现case语句的一个问题。就是指定小写字母[a-z]和大写字母[A-Z]的这种方法不管用了。

出现如下情况:

可以看到当输入大小写字母都会输出“Lowercase letter”

就当我疑惑不解的时候,奇迹发生了。。。。

当输入大写Z的时候,终于出现了我们想要的结果:Uppercase letter后来在man bash文档中也没有关于"-"代表范围的说明,值说想匹配"-",就把"-"放到[]中最前面或者最后面。case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esacA case command first expands word, and tries to match it against each pattern in turn, using the same matching rules as for pathnameexpansion (see Pathname Expansion below). The word is expanded using tilde expansion, parameter and variable expansion, arithmetic sub-stitution, command substitution, process substitution and quote removal. Each pattern examined is expanded using tilde expansion, param-eter and variable expansion, arithmetic substitution, command substitution, and process substitution. If the shell option nocasematch isenabled, the match is performed without regard to the case of alphabetic characters. When a match is found, the corresponding list isexecuted. If the ;; operator is used, no subsequent matches are attempted after the first pattern match. Using ;& in place of ;; causesexecution to continue with the list associated with the next set of patterns. Using ;;& in place of ;; causes the shell to test the nextpattern list in the statement, if any, and execute any associated list on a successful match. The exit status is zero if no patternmatches. Otherwise, it is the exit status of the last command executed in list.

再看下面这段代码:

可以看出来它的编码方式是:aAbBcCdDeE...yYzZ所以才会出现这种情况。这也算是一个小bug吧,如果想真的想达到我们想要的结果,可以用posix的[:upper:]。个人想法:有时候出现这种情况也不是个坏事,或许还可以利用这个bug去做点事。

推荐整理分享shell脚本中case条件控制语句的一个bug分析(linux脚本case),希望有所帮助,仅作参考,欢迎阅读内容。

shell脚本中case条件控制语句的一个bug分析(linux脚本case)

文章相关热门搜索词:shell case命令,shell case命令,shell脚本 case,shellcase语句,shellcase语句,shell脚本 case,shell脚本的case语句,shell脚本 case,内容如对您有帮助,希望把文章链接给更多的朋友!

shell编程基础之认识与学习BASH 1、认识Bash通过Shell将输入的指令与Kernel沟通,让Kernel控制硬件工作查看Shell:cat/etc/shell登录后预设的shell类型记录在/etc/passwd中,与账户相关命令别名:al

linux基础之Shell Script入门介绍 linux基础之ShellScript1ShellScipt使用指令和基本程序设计结构写成的程序,可以完成复杂的处理流程1.1程序书写#!/bin/bash#Program:#Thisprogramshows"HelloWrold"inyourscre

更改linux用户登录shell的操作方法 1、查看机器安装了哪些shell?有两种方法可以查看。第一种:[rocrocket@wupengchong~]$chsh-l/bin/sh/bin/bash/sbin/nologin/bin/zsh第二种:[rocrocket@wupengchong~]$cat/etc/shells

标签: linux脚本case

本文链接地址:https://www.jiuchutong.com/biancheng/376766.html 转载请保留说明!

上一篇:一个shell for循环与case结合的脚本(监控程序状态)(shell for循环执行命令)

下一篇:shell编程基础之认识与学习BASH(shell编程总结)

  • 其他权益工具投资属于什么科目
  • 建筑行业有哪种职业
  • 费用报销哪些可以不用合同的
  • 房租违约金收入怎么做账
  • 采购部差旅费会计分录怎么做
  • 长期股权投资的初始投资成本
  • 出让固定资产怎样计算增值税
  • 查增应纳税所得额怎么算
  • 公司回购房产契税谁交
  • 免税的农业企业可以抵扣专票吗
  • 没有收入是否可以入党
  • 发票是不是都一样
  • 会务费发票税率是
  • 小规模纳税人公司注销流程及费用
  • 进项税抵扣的房租怎么算
  • 发票章丢失风险大吗
  • 单位社保扣款
  • 电子发票截图可以吗
  • 无法查明原因的现金溢余计入什么科目?
  • 一般纳税人企业所得税税率2023
  • 可供出售金融资产是指什么
  • 支付工资资产减少了吗
  • 2020年运费发票备注栏新规定
  • 如何增加发票数量和额度
  • 赠送算商业用途吗
  • 企业合并的会计分录
  • linux 界面卡死
  • 教你怎么制作微信表情
  • 主板bios在线升级
  • 注册表编辑器误删怎么办
  • windows 11预览版
  • 怎么扣除税费
  • linux怎样使用
  • 家庭承包发包方的权利和义务
  • php公众号
  • 会计中的计算公式
  • 很值得收藏
  • 前端框架学哪个好
  • 刚成立的公司招人能去吗
  • 高新技术企业收入占比不到60%,能否享受税收优惠政策
  • Python 计算机视觉(八)—— OpenCV 进行图像增强
  • idea2021版本创建项目
  • promise基本使用
  • 退货业务增值税税务处理
  • 财政拨款结转的二级科目有哪些
  • 二季度报表是累计数吗
  • 发票走账不走账怎么处理
  • mongodb操作语句
  • 税务局清卡需要公章吗?
  • 以发行股票作为对价取得企业的股权
  • 企业向银行借入长期借款,应借记
  • 企业申报纳税都交什么税
  • 计提企业所得税的会计科目
  • 加盟费收入如何入账
  • 预付款开了增值税专票怎么办
  • 税控系统维护费可以全额抵扣吗
  • 水利建设基金缴纳增值税开始缴纳
  • 小企业会计准则以前年度损益调整
  • mysql 5.7.28安装
  • centos7升级内核后 无法启动
  • 系统问题怎么处理
  • linux中使用最多的命令
  • Ubuntu 8.10 Intrepid Ibex Alpha4 官方正式版下载
  • xp系统改win7系统设置
  • win7桌面右下角输入法图标不见了
  • winxp 证书错误
  • hyper v安装系统
  • win10系统出现问题怎么办
  • javascript字体属性
  • shell脚本用法
  • 安卓自定义acl文件
  • unity ugui组件
  • unity-Lightmapping
  • python文件与目录操作
  • 安卓手机如何查
  • python批量填表
  • 江西电子税务局官网app
  • 有限合伙企业怎么交税
  • 小微企业房产税优惠减免政策
  • 广西南宁地税局电话
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设