When you simply run
You can add these to your bashrc aliases:
alias grep='grep --color=always'
alias less='less -R'
grep --color
it implies grep --color=auto
which detects whether the output is a terminal and if so enables colors. However, when it detects a pipe it disables coloring. The following command:grep --color=always -R "search string" * | less -R
Will always enable coloring and override the automatic detection, and you will get the color highlighting in less
.You can add these to your bashrc aliases:
alias grep='grep --color=always'
alias less='less -R'
Perfect. Solution. Grep coloration appears in 'less' output just as in terminal. Thanks.
ReplyDelete