首页 > 系统服务 > 详细

linux命令---查找文件中的内容

时间:2015-06-03 23:22:08      阅读:339      评论:0      收藏:0      [点我收藏+]

linux命令---查找文件中的内容  

 

[yang@localhost ~]$ cat 1.txt |egrep ‘123456789|second‘-------匹配123456789或者second的行

first line:123456789012345678901234567890123456789012345678901234567890

second line:one two three four five six seven eight nine ten

 

[yang@localhost ~]$ cat 1.txt |egrep ‘two‘ |egrep ‘one‘----匹配two 且匹配one的行

second line:one two three four five six seven eight nine ten

 

[yang@localhost ~]$ cat 1.txt |grep ‘two‘ |grep ‘one‘----匹配two 且匹配one的行

second line:one two three four five six seven eight nine ten

 

 

[yang@localhost ~]$ grep -o 123456789 1.txt |wc -l  -----123456789出现的次数

6

[yang@localhost ~]$ cat 1.txt |grep -o 123456789 |wc -l    -----123456789出现的次数

6

[yang@localhost ~]$ more 1.txt |grep -o 123456789 |wc -l  -----123456789出现的次数

6

[yang@localhost ~]$

 

 

 

[yang@localhost ~]$ more 1.txt |grep -o ‘one..........two‘ |wc -l   -----------‘one..........two‘出现的次数,中间10个点表示隔了10个字

1

[yang@localhost ~]$ cat -n 1.txt |grep ‘one..........two‘      ----------匹配‘one..........two‘的行,中间10个点表示隔了10个字

    53     one1234567890two

[yang@localhost ~]$

linux命令---查找文件中的内容

原文:http://www.cnblogs.com/qmfsun/p/4550458.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!