grep result pipe to less get colors

如何讓 grep 查詢的結果管線到 less 也能呈現原有的顏色

# grep –color=always -R “search string" /var/log/* | less -Rgrep_color2_less

執行上述命令,讓 grep 篩選 /var/log/ 目錄下所有檔案含子目錄,檔案包含特定字串,將檔案名稱及符合字串行列出。最後交給 less 顯示原始樣式這樣輸出就能呈現出原有的顏色。

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s