位置: 编程技术 - 正文

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

  • 全国增值税发票查询平台 手机版
  • 4s店事故处理流程
  • 个体工商户定期定额征收个人所得税
  • 开具红字专用发票的条件
  • 分公司可以用总公司的业绩吗
  • 分公司小规模
  • 银行理财算投资吗
  • 劳务公司涉及的税收
  • 财务部门使用固定资产的折旧计入管理费用
  • 货发出款未收的会计分录怎么做?
  • 与其他企业联营算投资吗
  • 营业外支出可以扣除吗
  • 营改增之后账务怎么处理
  • 小额开专票
  • 携税宝报税操作流程
  • 定额发票使用年限规定
  • 收购发票盖章盖谁的
  • 出口分为哪四步
  • 发票抬头开错跨月了怎么办?
  • 技术服务费进项票会计分录
  • 代征税款手续费规定
  • 哪些发票公司可以抵扣
  • 滴滴出行电子发票备注怎么写
  • 当收到转账支票时,应该如何处理?
  • 退税收入怎么做分录
  • 收到预付账款会对企业财务有影响吗
  • sxgdsenu.exe - sxgdsenu是什么进程 有什么用
  • 帮忙介绍业务
  • 公司被收购后所需资金
  • 印花税哪里买
  • 可用保证金余额为负
  • 模型调参是调节什么
  • 单目深度估计算法
  • print函数php
  • 增值税专用发票的税率是多少啊
  • 无形资产的转让
  • 交税务局的工会经费现金流
  • 餐厅场租费可以开发票吗
  • 企业自建办公楼需要开发资质吗
  • 帝国cms使用手册
  • 增值税专用发票怎么开
  • 未满一年需要工商年报吗
  • 保险公司给员工奖励是违法的吗
  • 事业单位无形资产包括
  • 出售转让固定资产的账务处理
  • 其他应付款怎么冲平影响会计利润吗
  • 今年发的去年的工资怎么扣税
  • 港币转人民币怎么算
  • 现金流量少
  • 收到非税收入一般缴款书怎么分录
  • 购入研发设备可以抵扣吗
  • 其他应收款可以挂公司吗
  • 普通发票和增值税发票的区别图片
  • 销项减进项税额
  • 企业支付境外佣金要交税吗?
  • 建账的要点及应注意的问题
  • 账簿凭证的管理要求
  • sql server储存过程的创建与使用
  • Sqlserver中char,nchar,varchar与Nvarchar的区别分析
  • bios关闭光驱设置
  • win10edge浏览器默认主页网址
  • 无法ping通虚拟机
  • mission controller
  • 快速解决儿童鼻塞
  • rnbrcache.exe是什么意思
  • win10怎么启用网卡
  • cocos2dx4.0教程
  • 查看进程pid的命令是
  • js写贪吃蛇什么水平
  • node.js开发微信小程序
  • android车载导航刷机包
  • 技术总结2000字
  • js arrayfrom
  • 河北税务怎么看自己绑定的银行卡号
  • 发票查询打印如何操作
  • 北京公积金缴纳最低基数
  • 小规模国税申报表填写方法
  • 跨境电商出口商品结构
  • pppoe账号密码改了连不上网
  • 个人所得税没申报会退吗
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设