linux grep

25 篇文章 0 订阅

-c: --count 列数

-d: --directories 目录

-e: --regexp: 正则

-f: --file 规则文件

-l: --file-with-matches 匹配的文件

-L: --files-without-match 不符合的文件

-n: --line-number: 标出该行的列

-o: --only-matching: 只显示匹配的部分

-v: --revert-matching: 不包含匹配文本的所有行

-x: --line-regexp: 只显示全列符合的列

[root@k8s-master test1]# ll
总用量 8
-rw-r--r--. 1 root root 31 2月   8 16:02 test1.txt
-rw-r--r--. 1 root root 61 2月   8 15:44 test.txt
[root@k8s-master test1]# cat test1.txt 
abc
abcabc
def
abcdef
abcccdef
[root@k8s-master test1]# cat test.txt 
hello1
world
hello1world
hello1world221hello
this is a test!
[root@k8s-master test1]# grep abc .txt
grep: .txt: 没有那个文件或目录
[root@k8s-master test1]# grep abc *.txt
test1.txt:abc
test1.txt:abcabc
test1.txt:abcdef
test1.txt:abcccdef
[root@k8s-master test1]# grep abc *.txt -v
test1.txt:def
test.txt:hello1
test.txt:world
test.txt:hello1world
test.txt:hello1world221hello
test.txt:this is a test!
[root@k8s-master test1]# grep abc *.txt -v -n
test1.txt:3:def
test.txt:1:hello1
test.txt:2:world
test.txt:3:hello1world
test.txt:4:hello1world221hello
test.txt:5:this is a test!
[root@k8s-master test1]# grep abc *.txt -l
test1.txt
[root@k8s-master test1]# grep abc *.txt -L
test.txt
[root@k8s-master test1]# grep abc *.txt -o
test1.txt:abc
test1.txt:abc
test1.txt:abc
test1.txt:abc
test1.txt:abc
[root@k8s-master test1]# grep abc *.txt -c
test1.txt:4
test.txt:0
[root@k8s-master test1]# grep abc *.txt -x
test1.txt:abc
[root@k8s-master test1]# 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值