Grep 筆記 Mar 23rd, 2014 grep 某 pattern 時, 帶出前或後 n 行 含前二行 -B 2 (B:before) 1 cat /home/logs/php/vlog_patch.log | grep -B 2 'different' 含後二行 -A 2 (A:after) 1 cat /home/logs/php/vlog_patch.log | grep -A 2 'different' 搜尋檔案內容 ex: 搜尋 getInfo 字串 1 grep -Ri getInfo * # i 表示不分大小寫