Wednesday, May 8, 2024
 Popular · Latest · Hot · Upcoming
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 6464  / 3 Years ago, mon, july 19, 2021, 9:29:48

When I execute grep from within gnome-terminal, I get colored output - easily noticeable match, line-numbers (-n) with different colors etc



But when I execute exactly same grep command through bash script I get plane output, without coloring



Is there a way I can get colored output by using bash script?


More From » bash

 Answers
4

Using the --color option works for me out when I run grep inside of shell scripts.



Here is an example of what you want.



grep -n --color=auto "PATTERN" FILE

[#40679] Wednesday, July 21, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
antoccasiona

Total Points: 430
Total Questions: 127
Total Answers: 131

Location: Netherlands
Member since Sat, Jun 26, 2021
3 Years ago
antoccasiona questions
Sat, Oct 23, 21, 22:34, 3 Years ago
Sat, Sep 24, 22, 09:39, 2 Years ago
Sun, Jan 15, 23, 11:08, 1 Year ago
;