点击查看代码
cat  python.txt
# aa bb cc
#

#
# the is python
python 66 99 010
ttgt THE skkkoooppppp
aa bb ccc bet s ssacd
Adadad21321
Bdas2  better 3131
Cdaasdad4231412.
D asasdadas.
adsa adazzz.
2adsads thouasdada.
dsadsafas zz ou dada.
1sdafewrfwevv zzzzzzz ou daqweqe.




1.  过滤包含the的行     
grep the python.txt 

2.不区分大小写过滤包含the的行
grep -i the  python.txt

3.过滤不包含the的行
grep -v the python.txt 

4.过滤包含数字的行
grep "[0-9]" python.txt 
grep -P "\d" python.txt 

5.过滤包含bet或者better的行
grep -E "(bet|better)" python.txt

6.过滤包含2个字母o的行
grep oo python.txt
grep "o\{2\}" python.txt 
grep -E "o{2}" python.txt  

7.过滤包含1-2个字母o的行
grep "o\{1,2\}" python.txt 
grep -E "o{1,2}" python.txt 

8.过滤不包含字母o的行
grep -v "o" python.txt 

9.过滤大写字母开头的行
grep "^[A-Z]" python.txt 

10.过滤小写字母开头的行
grep "^[a-z]" python.txt

11.过滤ou前面不是th的行
grep -E "[^(th)]ou" python.txt 

12.过滤不以标点符号结束的行
grep -E  "[^.]$" python.txt

13.过滤空白行
grep "^$" python.txt 

14.过滤以.结尾的行
grep "\.$" python.txt 

15.过滤以数字开始的行
grep -E  "^[0-9]" python.txt

16.过滤包含2个以上z的行
grep "z\{2,\}" python.txt 
grep -E "z{2,}" python.txt 

17.过滤所有字母
grep "[a-zA-Z]" python.txt 

18.过滤所有标点符号
grep -P "\W" python.txt