位置: 编程技术 - 正文

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

  • 外贸企业税务处理方式
  • 未实际处置资产损失税前扣除金额的分录?
  • 年度纳税总额的时间怎么计算
  • 注册资本5块钱
  • 公司对公账户限额吗
  • 软件出口税收政策
  • 投资收益可以计入营业收入吗
  • 应计提的存货跌价准备
  • 无形资产摊销是谨慎性原则吗
  • 公司转投资的额度
  • 当期未开票过收入,以后开票怎么做会计分录
  • 取得抵债资产的方式主要有以下几种
  • 小型微利企业预缴所得税税率
  • 小规模纳税人设备税率
  • 建筑企业增值税预缴
  • 应征增值税不含税销售额是什么意思
  • 单位租房水电费是个人名字是否可以抵扣
  • 借库存商品贷生产成本这笔会计分录反映的经济业务是
  • 企业购买理财产品的会计分录
  • 购进货物赠送客户增值税处理
  • 公司代扣代缴的保险费有哪些
  • 并购动因理论有什么
  • 预缴附加税款会退税吗
  • mac电脑修改dns
  • 购入的无形资产
  • phpifelse
  • 银行贷款成本高
  • 移动列表格
  • 现金流量表补充资料怎么理解
  • 小程序封装网络怎么设置
  • 接受捐赠固定资产的改建支出
  • route命令的作用
  • zenity命令 显示图形框
  • convert convert
  • 事业单位用其他资金用于还单位贷款违法吗
  • 物业费税目
  • 查账征收的纳税人能否简易注销
  • 资产负债表季报是累计三个月数据吗
  • 股东之间股权转让流程
  • 网上银行跨行转账手续费
  • 银行利息怎么算10万块三年多少利息
  • 企业利润分配的含义
  • 小规模代开增值税专用发票怎么操作?
  • 开个人劳务票需要本人去吗
  • 代扣代缴增值税要交附加税吗
  • 一般纳税人的增值税税率
  • 消费税的计税方式有哪几种?
  • 设备租赁公司怎么样
  • 按照管理会计的解释,成本的相关性是
  • 转账支票需要知道开户行吗
  • 存货跌价准备的计算
  • 固定资产的核算包括
  • 存货期末报表列示
  • sql server233错误
  • xp剪贴板怎么打开
  • xp系统安装版如何安装
  • vssvc.exe
  • u大师教程
  • hpz12进程
  • macbook怎么把通知关掉
  • win7使用率
  • win7调出ie浏览器
  • win10升级 其他用户
  • win10专业版装不上m1136驱动
  • win7系统误删文件可以恢复吗
  • win8点设置没反应
  • win7的命令对话框在哪里
  • 批处理 >nul
  • cocos roadmap
  • linux dev/sr0
  • linux生成网卡配置文件
  • Android 为LinearLayout增加分割线 divider
  • asm/semaphore.h: No such file or directory
  • python运行py文件没反应
  • python 日期运算
  • 河北地方税务局网
  • 消费税纳税申报流程图
  • 年度纳税申报基础信息表怎么填
  • 一次性收入多少要交个人所得税
  • 烟叶税是谁交
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设