[問題] grep 擷取內容

作者: FierceBreast (兇奴王者)   2016-07-11 10:32:12
grep "要搜尋的關鍵字" 檔案名稱
依照上面的例子,就可以將檔案內容符合關鍵字的行數,擷取出來
但是今天我想要多擷取關鍵字加上關鍵字的下一行
比如說:
test.txt內容如下:
receive Hello
Welcome to DSGH
Please tell me your ID
我下grep "Hello" test.txt
會秀出 receive Hello
但是有什麼方法可以
receive Hello
Welcome to DSGH
秀出關鍵字外的那一行加上下一行
謝謝
作者: Neisseria (Neisseria)   2016-07-11 10:44:00
可以查 -A -B 參數,應該可以符合你的需求
作者: hpo14 (hpo14)   2016-07-11 23:46:00
先學會 man 跟 --help .....google 一下發問的智慧你會得到 RTFM

Links booklink

Contact Us: admin [ a t ] ucptt.com