位置: 编程技术 - 正文

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

  • 核定征收企业所得税率是多少
  • 个人出租住房需要缴纳哪些税
  • 公司被员工劳动仲裁
  • 工会经费和工会会员会费
  • 如何确定固定资产的原始价值
  • 为什么要进行建筑工程预算
  • 外聘人员需要申报个税吗
  • 金蝶专业版利润表本年累计公式
  • 存货盘盈涉税问题
  • 自制农产品采摘机器设备
  • 暂估成本结转后怎么冲回
  • 收到客户承兑怎么做账
  • 管家婆进货单科目名称怎么录入?
  • 分包挂靠认定依据
  • 补缴去年地税社保的会计分录怎么写?
  • 统计应交增值税怎么算
  • 国税2016年第53号公告解读
  • 股票内在价值计算公式中级财务管理
  • 机票抵扣增值税需要什么凭证
  • 代理销售怎么记账
  • 存货年末余额怎么算出来的
  • 修改远程桌面端
  • 电脑屏幕保护不能设置
  • 网页打不开是什么
  • 计提企业所得税费用会计分录
  • redhat5.6安装
  • 收到对方公司开出发票如何做账
  • 营改增后不动产发票
  • 生育津贴如何做账
  • js的发展历史
  • 已销售未出库如何结转成本
  • 预提费用的分录
  • 购买电脑固定资产怎么记账
  • 大前端需要掌握什么技能
  • matlab用于图像处理
  • yolov5中使用的限制目标宽高的方法防止梯度爆炸
  • 基于深度学习的图像超分辨率——综述
  • 纯HTML+CSS小兔鲜儿网站首页(静态网页)
  • phpcms如何配置404
  • 收到借款利息收入的会计分录怎么做账
  • 文化事业建设费的征收范围
  • 计提年终奖的会计分录
  • 马踏棋盘游戏规则
  • 印花税可以年底报一次
  • 实收资本何时入账
  • 增值税普通发票查询真伪
  • 管理费用主要包括
  • 框架合同的印花税
  • 企业特殊工种不备案可以补报备吗
  • 残保金少申报了怎么办
  • 什么是品种法?适用于什么范围?
  • 国债逆回购收益什么时候到账
  • 不良资产处置公司违法吗
  • 企业委托企业
  • 本月留抵增值税
  • 库存商品太多
  • 现金支票存根联丢失怎么办
  • 什么情况需要预缴
  • 普通发票作废的金额会扣税吗
  • 研发一个月多少钱
  • 没有期初数据,只要借贷平横,报表是不是就不会不平了?
  • Ubuntu16.04 server下配置MySQL,并开启远程连接的方法
  • macmini ubuntu
  • ubuntu系统如何
  • win10老是提示
  • winxp远程桌面
  • linux常用命令csdn
  • win10在哪里更改用户名
  • kpupgrader.exe是什么
  • win8.
  • win10预览版21390
  • win7点关机关不了
  • win8补丁官网
  • 将jquery.qqFace.js表情转换成微信的字符码
  • 基于python的设计
  • 提取字符串的公式
  • 每次开机windows桌面更新
  • python module import
  • unity随机生成一个物体
  • jquery源码解析
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设