Comments on: 20 Linux egrep Command Examples https://www.tecmint.com/egrep-command-examples/ Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks. Thu, 13 Jul 2023 09:45:01 +0000 hourly 1 By: Narendra K https://www.tecmint.com/egrep-command-examples/comment-page-1/#comment-1902187 Fri, 21 Oct 2022 11:41:12 +0000 https://www.tecmint.com/?p=28553#comment-1902187 In reply to dragonmouth.

@dragonmouth,

By default, the command uses red color for highlighting. However, we can control the behavior using the GREP_COLOR environment variables. For example, to use the yellow color, we can assign value 33 to the GREP_COLOR environment variable:

$ export GREP_COLOR=33

Please refer to https://www.tecmint.com/customize-bash-colors-terminal-prompt-linux/ to know more about colors in bash.

In example 14, the pattern match will succeed for all the files that are present under the dir1 as well as its subdirectories. For example, in the output, we can see that the pattern match succeeded for the file dir1/dir2/sample.txt.

]]>
By: dragonmouth https://www.tecmint.com/egrep-command-examples/comment-page-1/#comment-1901405 Wed, 19 Oct 2022 21:00:14 +0000 https://www.tecmint.com/?p=28553#comment-1901405 Your use of lines longer than the screen width in the sample.txt file is confusing.

“The below command will highlight the text professionals in red color:

$ egrep –color=auto professionals sample.txt”

That command WILL NOT highlight the matched pattern in RED. It will highlight the color that the variable “color” is set to which may or may not be RED.

In Example #14, shouldn’t you specify each directory or use a wild card? As written, the command will match the pattern only in the dir1 file(s).

]]>