位置: 编程技术 - 正文

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编程总结)

  • 不得税前扣除的贷款利息
  • 其他应付款包括哪些内容口诀
  • 应收利息和利息收入的关系
  • 逾期还款银行罚息怎么算
  • 营改增后哪些费用可以抵扣
  • 收取招标代理费会计分录
  • 收到货款定金计入哪里
  • 商品已发出未开票未收款怎么做账
  • 转让购入的设备税率
  • 个人名义帮公司贷款
  • 预付款可以开专票吗
  • 外籍人员个人所得税政策
  • 公司注销过了公示期不去有问题
  • 企业如何增加净资产
  • 中小五金企业如何进行成本核算
  • 工资薪金所得税前扣除项目标准
  • 办公用品收据可以入账吗
  • .exe文件怎么打不开
  • 汇算清缴当年分配的股息红利
  • 电脑系统权限管理在哪里
  • 外购固定资产的税率
  • dir852迅雷路由器
  • 固定资产未提完折旧停止经营怎么处理
  • 扫码分享到微信
  • 国有资产无偿使用违反什么规定
  • 企业年金在缴费阶段涉及的税种包括
  • 公共基础设施的英语
  • 子公司使用母公司授信
  • linuxweb服务器搭建教程
  • 固定资产清理税务处理
  • 阿布鲁佐的特点
  • 期间费用计算公式
  • 马萨诸塞 下架
  • linux+php
  • 公司法人和股东哪个承担的责任大
  • vue项目开发环境
  • 商企预提待付的钱怎么办
  • 国税网如何下载申报后的财务报表
  • 个税网上申报流程视频
  • 帝国cms仿站工具
  • php 清除缓存
  • 预收账款的销售分录
  • 小规模纳税人升为一般纳税人条件
  • 资金占用费的税费是多少
  • 应付账款账务处理中的错弊
  • 进口环节缴纳关税计入什么科目
  • 职工工伤住院期间的各项费用由谁负责
  • 企业分配利润的原因
  • 多交的税费申请抵扣下期
  • 工程项目增值税预缴税率
  • 12月收入1月份开发票怎么报企业所得税
  • 购货方享受现金折扣增值税
  • 银行日记账的登记依据有哪些
  • 红字专用发票怎么做账
  • 贴现到期后
  • 旅客运输进项税申报漏了
  • 结转未交增值税会计处理
  • access数据库sql语言
  • mysql 连续日期
  • centos7如何设置ssh免密登陆
  • exe文件xp3
  • windows7hosts文件
  • 找不到config/index taro
  • win7安装内存4g
  • 常见的错误方法
  • perl实例
  • jquery从入门到精通
  • 判断一个点在三角形内部
  • js实现点击按钮移动滑块到另一个按钮的方法
  • python内置方法大全
  • js设置rem
  • javascript要怎么学
  • python中redis的用法
  • python读取linux文件
  • 江苏省全电发票开通流程
  • 研发材料占研发费用比例超出50%
  • 润泽一词出自哪里
  • 百旺金赋天津客服
  • 税务开通需要什么东西
  • 增值税纳税申报表附列资料(三)
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设