- 实例1:找出http://www.baidu.com,或者http://www.baidu.com并且https://www.baidu.com
新建文本 example2.grep如下:
test@sha:~/tmp> cat example2.grep
httpwww.baidu.com
httpwwwbaiducom
httpwwwbaidu.com
http:wwwbaiducom
https:www.baidu.com
abchttp://www/baidu.comcde
baidu.com
baidu
找出http://www.baidu.com
test@sha> grep -r '^http://www\.\bbaidu\b\.com$'example2.grep
找出http://www.baidu.com和https://www.baidu.com
test@sha> grep -r '^https\{0,1\}://www\.\bbaidu\b\.com$'example2.grep
新建文本example3.grep如下:
jack@qq.com
Mary@qq.com
Mike.li@qq.com
snow_chen@qq.coim
jack_2@hotmail.com
jack_3@qq.com
jack@.com
13345678921@qq.com
aaa@gmail.com
a@bc@qq.com
@@baidu.com
_abc@qq.com
.@qq.comi
abc+abc@qq.com
找出所有合规的邮件地址
test@sha> grep -i -E'^[a-zA-Z0-9_]+[a-z.]*@[a-zA-Z0-9]+\..*' example3.grep
jack@qq.com
Mary@qq.com
Mike.li@qq.com
snow_chen@qq.coim
jack_2@hotmail.com
jack_3@qq.com
13345678921@qq.com
aaa@gmail.com
_abc@qq.com
找出所有不合规的邮件地址
test@sha> grep -i -E '^[^a-zA-Z0-9_]*@'example3.grep
@@baidu.com
.@qq.comi