linux 常用命令 - grep
2017-09-08 09:50
162 查看
匹配多个关键词
用法:grep -E ‘your regular expression’ file举例:我们拿冰与火之歌第七季第七集的部分字幕举个例子。
GameOfThrones.txt
30 00:04:14,370 --> 00:04:19,370 {\an8}{\pos(94.16,212.825)}app.YYeTs.com 37 00:00:08,070 --> 00:00:11,100 Little Theon! Come and get her. 38 00:00:19,300 --> 00:00:22,650 It's an invitation... to King's Landing. 39 00:00:22,650 --> 00:00:25,820 You will represent my interests at this gathering as you see them. 40 00:00:25,820 --> 00:00:28,540 It's not safe leaving you with Littlefinger. 41 00:00:28,540 --> 00:00:29,870 She's your sister.
匹配GameOfThrones.txt中含有’sister’或’King’的行
[~/shell]$ grep -E 'sister|King' GameOfThrones.txt It's an invitation... to King's Landing. She's your sister.
匹配GameOfThrones.txt中含有’sister’或’King’或’Little Theon’的行
注意’Little Theon’中间有个空格,这个时候就要用到正则表达式了Little.Theon,正则表达式中.代表任意字符。
[~/shell]$ grep -E 'sister|King|Little.Theon' grep2.txt Little Theon! Come and get her. It's an invitation... to King's Landing. She's your sister.
相关文章推荐
- Linux常用命令-find grep
- linux常用命令练习:grep具体使用实例
- Linux常用命令:grep 命令
- 【日常小记】linux中强大且常用命令:find、grep
- linux常用命令之 sed grep awk
- Linux常用命令52:grep 命令
- Linux--常用命令--grep
- Linux常用命令之grep
- 【转载】Linux中强大且常用命令:find、grep
- Linux grep命令常用参数一览
- linux中强大且常用命令:find、grep
- [linux常用命令] 2、强大的搜索指令grep
- 查看linux代码的常用命令(find,grep)
- linux 常用用命令-grep
- Linux常用搜索命令grep命令
- linux常用命令学习之grep命令
- Linux常用命令——搜索which,whereis,slocate,find,grep
- Linux常用命令之whereis,which,find和grep命令
- linux中强大且常用命令:find、grep
- Linux中强大且常用命令:find、grep