作者FierceBreast (兇奴王者)
看板Linux
標題[問題] grep 擷取內容
時間Mon Jul 11 10:32:12 2016
grep "要搜尋的關鍵字" 檔案名稱
依照上面的例子,就可以將檔案內容符合關鍵字的行數,擷取出來
但是今天我想要多擷取關鍵字加上關鍵字的下一行
比如說:
test.txt內容如下:
receive Hello
Welcome to DSGH
Please tell me your ID
我下grep "Hello" test.txt
會秀出 receive Hello
但是有什麼方法可以
receive Hello
Welcome to DSGH
秀出關鍵字外的那一行加上下一行
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.117.89.82
※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1468204335.A.115.html
→ Neisseria: 可以查 -A -B 參數,應該可以符合你的需求 07/11 10:44
→ hpo14: 先學會 man 跟 --help ..... 07/11 23:46
→ hpo14: google 一下發問的智慧你會得到 RTFM 07/11 23:46