定义
简单的来说就是用在字符串的处理上面的一项表达式。
基础表达式
注意:不同的环境语系会导致不同选取结果,这里以LANG=C为例子。
常用特殊符号:
特殊符号 | 代表意义 |
---|---|
[:alnum:] | 代表英文大小写字符以及数字 |
[:digit:] | 代表数字 |
[:alpha:] | 代表英文大小写 |
[:blank:] | 代表空格键和tab键 |
[:lower:] | 代表小写字符 |
[:upper:] | 代表大写字符 |
[:xdigit:] | 代表十六进制的数字类型 |
这里的可以用[a-z],[0-9]替代 |
基础命令
grep - [acinv]
i:不区分大小写
n:列出行号
v:取反操作
c:计算找到字符串的次数
a:将binary文件以text文件的方式查找数据
为方便下面的操作,我们需将系统环境设置为LANG=C,以及在~/.bashrc内加入alias grep=‘grep -color=auto’,最后source ~/.bashrc即可。
练习文件摸我
Of course you can use command to get this file.
wget http://linux.vbird.org/linux_basic/0330regularex/regular_express.tx
And you can see what’s inside by using cat command
➜ Desktop cat regular_express.txt
"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
Now let’s start to do something with this file. For example, i want to know