Archive for July 4th, 2007

console output highlighter

Wednesday, July 4th, 2007

我常常要在一堆 output 中找特定關鍵字,通常是透過 sed 來加上顏色,不過剛剛覺得一大串指令很煩,寫了個簡單的 script 包起來了

下載 highlighter

使用方式很簡單

some_program | hl <keyword> [<ansi color code>]

或是

hl <keyword> [<ansi color code>] < some_file

這邊的 ansi color code 只要填數字的部份,不用加上前面的 Esc[ 與最後的 m

多個關鍵字比較麻煩,目前只能多跑幾次

some_program | hl <keyword1> | hl <keyword2> [ | hl …]