Shell三剑客:正则表达式(元字符)——示例

  • grep love 1.txt
  • /^love/
  • /love$/
  • /l.ve/
  • /lo*ve/
  • /[Ll]ove/
  • /love[a-z]/
  • /love[^a-zA-Z0-9]
  • /.*/
  • /^$/
  • /^[A-Z]..$"/
  • /^[A-Z][a-z]*3[0-5]/
  • /[a-z]*\."/
  • /^*[A-Z][a-z][a-z]$"/
  • /^*[A-Za-z]*[^,][A-Za-z]*$/
  • /\<fourth\>/
  • /\<f.*th\> /
  • /5{2}2{3}\./
  • /^[\t]*$/
  • /^#/
  • /^[\t]*#/
  • :1,$ s/\([Oo]ccur\)ence/\1rence/ 
  • :1,$ s /\(square\) and \(fair\)/\2 and \1/ 
[root@localhost ~]# grep "^$" 1.txt 
[root@localhost ~]# grep ".*" 1.txt 
#qian
#yoa
#huang
kai
kong
cai
[root@localhost ~]# grep "^$" 1.txt 
[root@localhost ~]# grep "[A-Z]..$" 1.txt 
[root@localhost ~]# grep "[^A-Z]..$" 1.txt 
#qian
#yoa
#huang
kai
kong
cai
duo
[root@localhost ~]# grep "^[A-Z]..$" 1.txt 
[root@localhost ~]# grep "^[A-Z][a-z]*3[0-5]" 1.txt 
[root@localhost ~]# grep "[a-z]*\." 1.txt 
l.ve
[root@localhost ~]# grep "^*[A-Z][a-z][a-z]$" 1.txt 
[root@localhost ~]# grep "^*[A-Za-z]*[^,][A-Za-z]*$" 1.txt 
[root@localhost ~]# grep "\<fourth\>" 1.txt 
[root@localhost ~]# grep \<fourth\> 1.txt 
[root@localhost ~]# grep \<f.*th\> 1.txt 
[root@localhost ~]# grep "5{2}2{3}\." 1.txt 
[root@localhost ~]# grep "^[\t]*$" 1.txt 
[root@localhost ~]# grep "^#" 1.txt 
#qian
#yoa
#huang
[root@localhost ~]# grep "^[\t]*#" 1.txt 
#qian
#yoa
#huang
:1,$ s/\([Oo]ccur\)ence/\1rence/ 
:1,$ s /\(square\) and \(fair\)/\2 and \1/ 

 

 

 

 

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-15 07:32:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-15 07:32:04       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-15 07:32:04       82 阅读
  4. Python语言-面向对象

    2023-12-15 07:32:04       91 阅读

热门阅读

  1. C++学习-2023/12/14-C++类和对象

    2023-12-15 07:32:04       52 阅读
  2. 计算机网络——习题——书上原题

    2023-12-15 07:32:04       46 阅读
  3. H3CIE_IS专题

    2023-12-15 07:32:04       48 阅读
  4. Android 13 - Media框架(22)- ACodec(四)

    2023-12-15 07:32:04       116 阅读
  5. bootstrap是什么

    2023-12-15 07:32:04       53 阅读
  6. Shell 中的 ${} 和 $() 的区别

    2023-12-15 07:32:04       47 阅读
  7. C++某张不知名试卷

    2023-12-15 07:32:04       46 阅读
  8. el-upload添加FormData参数,自定义上传接口

    2023-12-15 07:32:04       52 阅读
  9. OpenCV imencode 函数详解与应用示例

    2023-12-15 07:32:04       56 阅读
  10. 100道Linux系统面试题(含答案)

    2023-12-15 07:32:04       45 阅读
  11. Vue+scss实现全局字体大小切换

    2023-12-15 07:32:04       72 阅读