检索文本例子结合sed,head,tail,cut
来源:互联网 发布:it人才网 编辑:程序博客网 时间:2024/05/02 05:06
有如下文本
[root@hadoop ~]# cat s.txt
head test
head test again
weihongrao start
this is going
weihongrao is stupy
weihongrao is the ruler
endweihongrao but still going
endweihongrao this is true end
something
nothing
nothing or somthing in test
just test line
假如我需要检索第一次开头出现weihongrao 到最后一次开头出现endweihongrao之间所有的行
[root@hadoop ~]#s=$(grep -n "^weihongrao" s.txt |head -1 |cut -d':' -f1)
[root@hadoop ~]# e=$(grep -n "^endweihongrao" s.txt |tail -1 |cut -d':' -f1)
[root@hadoop ~]# sed -n "${s},${e}p" s.txt
weihongrao start
this is going
weihongrao is stupy
weihongrao is the ruler
endweihongrao but still going
endweihongrao this is true end
0 0
- 检索文本例子结合sed,head,tail,cut
- head , tail , sort ,cut
- awk,sed,grep,cut,uniq,sort,tr,wc,head,tail的常见用法
- linux head tail sed用法
- cut、sort、tr、wc、head、tail
- shell删除文本技巧 —— grep, cut, head, sed, awk
- linux查看文件命令 head sed tail
- 文本查看命令 - head和tail
- linux 基础2-null,cut,wc,head,tail
- 高级命令行文本处理cut,sed,awk
- [转] 文件内容查看 cat,less,more,tail,head,sed
- 文件内容查看 cat,less,more,tail,head,sed
- Linux常用命令head,tail,grep,sed,yum,find
- head&&tail
- 使用 head 和 tail 以块方式读取文本流
- [SHELL]:查看文本内容的命令:head,tail
- Linux文本数据提取之head,tail实例详解
- Linux 查看文本命令(cat tac rev head tail)
- iframe实现局部刷新和回调(转)
- 待写
- Java - 关于InputStream,InputStreamReader和BufferedReader
- js
- PJSIP UA分析(2)--PJSUA注册
- 检索文本例子结合sed,head,tail,cut
- error:误以为闰年就是能被4整除的数
- C语言运算符优先级(超详细)
- c语言的头文件#include <limits.h>
- 有经验的Java开发者和架构师容易犯的10个错误
- YUV格式解析
- 多态与继承(上)
- SVN自动备份命令记录
- ORA-00600: internal error code, arguments: [2032]