grep
基本匹配:
grep a*re hello.txt --* 代表多个任意字符
grep a.re hello.txt -- .代表re前面任意多个a
grep "...re" hello.txt --打印re前面有三个字符的字符串
grep '[xz]k' hello.txt --打印k前面带有x或者k的字符串
grep '[^xz]k' hello.txt --打印k前面不带有x和 =k的字符串
扩展匹配: grep -E 或者 在选项前加转义字符 \ 如:grep a\+re hello.txt
grep -E "a{3}re" hello.txt --{3}代表出现3个以上的a的字符串
匹配符
- \ 转义字符 + \< >
- . 匹配任意单个字符
- [1234abc] , [^1234] , [1-5], [a-d] 字符序列单字符占位
- ^ 行首 如:^.k 代表以第二个字符为k开头的单词
- $ 行尾
- \
- | 连接操作符
- (,) 选择操作符
- \n 反向引用
Original: https://www.cnblogs.com/Boyka1/p/15366180.html
Author: 程胥员
Title: grep
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/598538/
转载文章受原作者版权保护。转载请注明原作者出处!