linux搜索文件内容源码,linux命令---查找文件中的内容

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

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

first line:123456789012345678901234567890123456789012345678901234567890

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

[[email protected] ~]$ cat 1.txt |egrep ‘two‘ |egrep ‘one‘----匹配two且匹配one的行

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

[[email protected] ~]$ cat 1.txt |grep ‘two‘ |grep ‘one‘----匹配two且匹配one的行

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

[[email protected] ~]$ grep -o 123456789 1.txt |wc -l  -----123456789出现的次数

6

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

6

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

6

[[email protected] ~]$

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

1

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

53     one1234567890two

[[email protected] ~]$

时间: 06-01

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值