环境

 [root@osker ~]# cat /etc/redhat-release
CentOS Linux release 7.6. (Core)
[root@osker ~]# uname -r
3.10.-.el7.x86_64
1 [root@osker ~]# cat 3.txt
2 Mike Harrington:[510] 548-1278:250:100:175
3 Christian Dobbins:[408] 538-2358:155:90:201
4 tom
5 Chet Main:[510] 548-5258:50:95:135
6 Tom Savage:[408] 926-3456:250:168:

文档中有tom和Tom两个关键词

vim
:set ic   (ignorecase 的缩写)忽略大小写
:set noic  (noignorecase 的缩写)不忽略大小写

grep
查询man帮助可以找到,使用-i参数可以忽略大小。
-i, --ignore-case:Ignore case distinctions in both the PATTERN and the input files.  (-i is specified by POSIX.)

 [root@osker ~]# grep -i 'tom' .txt
tom
Tom Savage:[] -:::

sed

 [root@osker ~]# sed -n '/tom/Ip' .txt
tom
Tom Savage:[] -:::
[root@osker ~]# sed -n '/tom/ip' .txt
p

可以看出在/后加入 I 可以忽略大小写过滤,使用i会出错。

 [root@osker ~]# sed -n 's#tom#qiu#gp' .txt
qiu
[root@osker ~]# sed -n 's#tom#qiu#gpi' .txt
qiu
qiu Savage:[] -:::
[root@osker ~]# sed -n 's#tom#qiu#gpI' .txt
qiu
qiu Savage:[] -:::

在使用替换功能时候可以时用i或者I,对需要替换的词忽略大小写。
在GNU找了好久,找到这么一段话:
i I :The I modifier to regular-expression matching is a GNU extension which makes sed match regexp in a case-insensitive manner.
引用链接:
https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.html#The-_0022s_0022-Command

awk

 [root@osker ~]# awk '/tom/' IGNORECASE= .txt
tom
Tom Savage:[] -:::

查看man帮助可以查询到,awk内置了一个IGNORECASE变量,专门用于处理大小写的忽略。当IGNORECASE的值为真时,则进行忽略大写的匹配。
IGNORECASE:
Controls the case-sensitivity of all regular expression and string operations.  If IGNORECASE has a non-zero value, then string comparisons and pattern matching in rules, field splitting with FS and FPAT, record separating with RS, regular expression matching with ~ and  !~,  and  the  gensub(),  gsub(),  index(),  match(),  patsplit(),  split(),  and  sub()  built-in  functions  all  ignore  case when doing regular expression operations.  NOTE: Array subscripting is not affected.  However, the asort() and asorti() functions are affected.
Thus, if IGNORECASE is not equal to zero, /aB/ matches all of the strings "ab", "aB", "Ab", and "AB".  As with all AWK variables, the initial value of IGNORECASE is zero, so all regular expression and string operations are normally case-sensitive.

最新文章

  1. MsSQLserver中修改字段值系统自动生成的脚本
  2. 建模算法(四)——动态规划
  3. sqlite报错OutOfMemory
  4. 1.4.2 solr字段类型--(1.4.2.7)字段属性使用案例
  5. 进程关系之tcgetpgrp、tcsetpgrp和tcgetsid函数
  6. Go与GUI——GO语言的图形界面Walk
  7. spring线程池配置
  8. Git push 时每次都需要密码的疑惑
  9. poj 2432 Around the world bfs+哈希
  10. 浅谈c语言程序为什么需要内存 栈又是什么?
  11. 强制IE浏览器或WebBrowser控件使用指定版本显示网页
  12. E-mail Composition and Decoding
  13. SQLite基础回顾
  14. Command "python setup.py egg_info" failed with error code 1一种问题的解决方法
  15. Java实现大数相加、相乘(不使用BigInteger)
  16. MongoDB数据库中更新与删除数据
  17. 使用gulp和bable实现实时编译ES6代码
  18. python(nmap模块、多线程模块)
  19. 【洛谷p2142】高精度减法
  20. jquery ajax 无刷新上传

热门文章

  1. C++ 重载关系操作符
  2. RPA如何跑赢传统自动化和人工?
  3. 《自拍教程46》Python_adb自动拍照100张
  4. vscode在执行 npm任务的时候,会先执行package的name@version 然后命令名 加 当前路径,问题是我的引入路径e是小写的,会导致调试错误,解决方案:没找到,先手书吧
  5. 微信小程序开发(一)开发工具推荐VSCode
  6. 关于Addressable的疑问
  7. JDBC工具类实现登陆验证-Java(新手)
  8. 网络安全从入门到精通 (第二章-4) 后端基础PHP—简介及基本函数-上
  9. Docker学习-私有仓库docker-registry的使用
  10. div或者p标签单行和多行超出显示省略号