sed 与正则表达式组合应用(一)
来源:互联网 发布:2017淘宝全国排名 编辑:程序博客网 时间:2024/04/29 04:33
sed 与正则表达式组合格式
sed ‘/正则表达式/sed命令‘
1、区分大小写
$ echo "This is a test" |sed -n '/this/p'
$ echo "this is a test" |sed -n '/this/p'this is a test
2、模式匹配的文本要大于或等于 表达式集合
The books are expensive
$ echo "The book are expensive" | sed -n '/books/p'
$ echo "The books are expensive" | sed -n '/book/p'
The books are expensive
$ echo "This is line number 1" | sed -n '/number 1/p'
This is line number 1
3、识别空格
This is a normal line of text.
This is a line with too many spaces.
$ sed -n '/ /p' data1
This is a line with too many spaces.
4、支持定位符^ $
$ echo "book store" | sed -n '/^book/p'
book store
$ echo "This ^ is a test" | sed -n '/s ^/p'
This ^ is a test
$ cat data4
this is a test of using both anchors
I said this is a test
this is a test
I'm sure this is a test
$ sed -n '/^$/d' data4
$ sed '/^$/d' data4
this is a test of using both anchors
I said this is a test
this is a test
I'm sure this is a test
5、支持. 字符代替任何字符
$ cat >data6
This is a test of a line
The cat is sleeping.That is a very nice cat.
This test is at line four.
at ten o'clock we'll go home.
$ sed -n '/.at/p' data6
The cat is sleeping.
That is a very nice cat.
This test is at line four.
- sed 与正则表达式组合应用(一)
- 轻松上手 正则表达式与grep,sed,awk(一)
- 正则表达式 && sed应用
- 正则表达式与grep、sed
- 正则表达式应用(一)
- JavaScript常用正则表达式与应用(一)
- sed配合正则表达式应用案例
- [收藏] 正则表达式的入门与应用,1~4篇!grep/sed/perl/awk
- [收藏] 正则表达式的入门与应用,1~4篇!grep/sed/perl/awk
- [收藏] 正则表达式的入门与应用,1~4篇!grep/sed/perl/awk
- [收藏] 正则表达式的入门与应用,1~4篇!grep/sed/perl/awk
- 正则表达式Sed
- sed中的正则表达式
- sed正则表达式
- sed 命令+正则表达式
- 正则表达式、sed、awk
- sed 之正则表达式
- sed 命令+正则表达式
- 2011年终总结 转载
- 百万不是梦!盘点2012年六大IT高薪岗位
- 游戏定宣传片制作攻略
- 超强的计算型知识引擎wolframalpha
- 【JAVA优化编程】内存管理之——(1)垃圾回收
- sed 与正则表达式组合应用(一)
- vs2005如何把类视图等,从右边移到左边
- BMP文件格式分析
- 解决iphon,ipad上2次点击
- Linux内核学习之链表
- 【JAVA优化编程】内存管理之——(2)JVM中对象的生命周期
- Qt读写注册表和ini文件
- Android 应用布局文件的命名规则
- vc 6.0 堆栈错误一例