手记

linux-grep

1、grep 过滤关键字:

(1)满足或:-E ;满足多个关键字(或的关系)的过滤:-E  grep -E "min1|min2|min3" file.txt

(2)多个关键字同时满足: grep | ;同时满足多个关键字:grep "min1" file.txt | grep "min2" | grep "min3"

(3) 排除:-V  ;grep -V "min1|min2" file.txt

(4)行号:-n ;打印哪些行包含关键字信息:grep -i -n "test" file.txt

(5)数量统计:-c ;统计包含多少行关键字内容:grep -i -c "test" file.txt

(6)关键字打印:-o ;只打印匹配的关键字信息:grep -i -o "test" file.txt



1人推荐
随时随地看视频
慕课网APP