-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]#