1. 程式人生 > 實用技巧 >linux三劍客之grep

linux三劍客之grep

Matching Control

-i :Ignore case 忽略大小寫
在這裡插入圖片描述

-w:whole words 按照整個單詞匹配
在這裡插入圖片描述

-v:Invert the sense of matching, to select non-matching lines 匹配不包含指定關鍵字的行
在這裡插入圖片描述

Output Line Prefix Control

-n:line number 在行前顯示行號
在這裡插入圖片描述

Context Line Control

-A NUM:Print NUM lines of trailing context after matching lines. 顯示關鍵字所在行的後NUM行

-B NUM:Print NUM lines of leading context before matching lines. 顯示關鍵字所在行的前NUM行

-C NUM:Print NUM lines of output context 顯示關鍵字前後NUM行
在這裡插入圖片描述

General Output Control

-c :print a count of matching lines 列印匹配關鍵在所在行的個數
在這裡插入圖片描述