grep正则表达式(二)
来源:互联网 发布:数据服务 编辑:程序博客网 时间:2024/05/20 11:46
任意字符(The Any Character)
dot or period character: “.”
grep -h '.zip' dirlist*.txt
“.”代表任意字符,但是zip
不符合,因为”.”必须代表一个字符。所以符合条件的字符串至少要含4个字符。
bunzip2bzip2bzip2recovergunzipgzipfunzipgpg-zippreunzipprezipprezip-binunzipunzipsfx
锚定字符(Anchors)
beginning of the line “^”
end of the line “$”
grep -h '^zip' dirlist*.txt
字符串必须以”zip”开头:
zipzipcloakzipgrepzipinfozipnotezipsplit
grep -h 'zip$' dirlist*.txt
字符串必须以”zip”结尾
gunzipgzipfunzipgpg-zippreunzipprezipunzipzip
两个比较特殊的情况:
grep -h '^zip$' dirlist*.txt
只有字符串zip
符合。
grep -h '^$' dirlist*.txt
代表 blank lines 空白行
方括号表达式[]
grep -h '[bg]zip' dirlist*.txt
查找包含bzip
或gzip
的字符串。注意:
所有字符或元字符(metacharacter)放在方括号里都会失掉特殊含义,除了两个特例:^
和-
。例如:
否定(Negation)^
grep -h '[^bg]zip' dirlist*.txt
查找包含zip
的字符串,但是不能是bzip
或gzip
。
grep -h '^[A-Z]' dirlist*.txt
查找以26个大字字母开头的字符串。-
在这里是 range。
阅读全文
0 0
- grep正则表达式(二)
- grep 正则(二)
- grep正则表达式(一)
- grep用法详解:grep与正则表达式(转)
- Linux学习之十grep及正则表达式(grep)
- 正则表达式(grep,egrep,fgrep)
- 正则表达式(grep,egrep,fgrep)
- grep命令使用-正则表达式(zz)
- 正则表达式(grep,egrep,fgrep)
- grep 正则表达式
- 正则表达式之grep
- grep 与正则表达式
- UNIX:grep正则表达式
- 【转】grep正则表达式
- 正则表达式之grep
- 正则表达式在grep
- Grep,正则表达式
- grep 与正则表达式
- 1020. 月饼 (25)
- 单例模式+Java
- CSDN我又回来了
- C语言梳理指针的混淆点
- LinuxKernelDevelopment_读书笔记
- grep正则表达式(二)
- 无法访问虚拟机no route to host 解决 .
- c++4
- 《Core Java》读书笔记——第4章
- iOS防止用户截屏
- duilib 内存画图
- Servlet线程安全解析
- 内存栅栏:软件高手的硬件观(四)
- BZOJ 3669: [Noi2014]魔法森林 LCT