Linux之正则表达式与文件格式化处理

来源:互联网 发布:美国大选辩论 知乎 编辑:程序博客网 时间:2024/05/13 02:14

正则表达式主要是用在对字符串进行处理。注意一点的是正则表达式与通配符是完全不一样的东西,开机过程中的相关程序都在/etc/init.d

1.grep详解

grep最重要的功能就是进行数据比对时,然后将符合要求的字符串打印出来,注意grep在数据查找时,是以一个“整行”为单位来进行数据获取的
以下面这个文本为例子解释grep。

"Open Source" is a good mechanism to develop programs.apple is my favorite food.Football game is not use feet only.this dress doesn't fit me.However, this dress is about $ 3183 dollars.GNU is free air not free beer.Her hair is very beauty.I can't finish the test.Oh! The soup taste good.motorcycle is cheap than car.This window is clear.the symbol '*' is represented as start.Oh! My god!The gd software is a library for drafting programs.You are the best is mean you are the no. 1.The world <Happy> is the same with "glad".I like dog.google is the best tools for search keyword.goooooogle yes!go! go! Let's go.# I am VBird
  1. 搜索特定字符串
    搜索带有’the’
    这里写图片描述
    反向搜索,搜索没有’the’的
    这里写图片描述
    要取得部分大小写的’the’字符串
    这里写图片描述
  2. 利用中括号[]来搜索集合字符
    这里写图片描述
    如果要搜索带有’oo’的字符
    这里写图片描述
    这里写图片描述
    我想’oo’字符前没有小写字母
    这里写图片描述
    要取有数字的一行
    这里写图片描述
    也可以这样
    这里写图片描述
    423
1 0
原创粉丝点击