linux關鍵字查詢

2021-10-06 02:31:52 字數 1249 閱讀 7942

指定單個檔案查詢

方法一:cat test.log | grep 「關鍵字」

方法二:grep -i 「關鍵字」 ./test.log

關鍵字查詢日誌,並顯示該條日誌的前後n(10)行記錄

cat test.log | grep -b10 -a10 「關鍵字」

從當前目錄的所有.log檔案中查詢內容關鍵字是「test」檔案

find -name 『.log』 | xargs grep -l 「test」

或者find -name '.log』 exec grep -l 『test』{}\;

查詢日誌尾部最後50行的日誌

tail -n 50 test.log

查詢10行之後的所有日誌

tail -n +10 test.log

查詢日誌檔案中的頭10行日誌

head -n 10 test.log

查詢日誌中除了最後10行的其他所有日誌

head -n -10 test.log

查詢指定時間段的日誌

sed -n 『/2020-01-01 13:10:10.294/, /2020-01-01 14:10:10.294/p』 test.log

關鍵字搜尋指定時間段的日誌

sed -n 『/2020-01-01 13:10:10.294/, /2020-01-01 14:10:10.294/p』 test.log | grep 「關鍵字」

查詢的日誌匯出。匯出到當前目錄,l l檢視一下當前目錄是否存在

sed -n 『/2020-01-01 13:10:10.294/, /2020-01-01 14:10:10.294/p』 test.log > 匯出日誌.txt

檢視日誌前n行

cat test.log | head -n 200

檢視日誌尾n行

cat test.log | tail -n 200

關鍵字查詢

題目描述 每次給你一篇文章,和一些關鍵字,需要你告訴我多少關鍵字將匹配於文章。輸入描述 第一行包含乙個整數,表示有多少篇文章。最後一行是文章,長度不超過1000000。輸出描述 輸出文章中包含多少關鍵字。輸入樣例 15 shehe sayshr heryasherhs 輸出樣例 3源 include...

linux指令碼查詢關鍵字替換

來自http www.linuxforum.net forum showflat.php?cat board vrml number 510962 page 20 view collapsed sb 5 o all fpart 一 grep l r keyword while read a do s...

AngularJS關鍵字查詢

按貨物數量反序排序 按貨物入庫時間正序排序 按貨物入庫時間反序排序 入庫貨物名稱 貨物數量 貨物產地 貨物單價 貨物入庫時間日期操作 刪除mo.controller myctrl function scope 刪除 scope.del function delname else 定義下拉列表的排序 ...