How to add 'color' in a grep?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers How to add 'color' in a grep?
# 8  
Old 01-09-2019
In addition to post 6, I've always noticed this and have to add an extra grep to the end of lines pipe connected sequences (probably badly written Smilie) to get the output I want highlighted. I usually use use an expression that matches every line too, so in your case I would append the following:-
Code:
........ | egrep --color -Ei "|abcd"

... so I'm matching your string abcd or a null (every line, but no character) to get all the output and colour the important characters.

You might be able to remove your existing grep -Ei 'abcd' and just use the above at the end, but it depends if that might leave too many records to be processed by your tr. By 'too many', I'm thinking of over 100,000 unneeded records, such a volume that might slow your overall pipeline.


I hope that this helps,
Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add Color To html Doc

I have a script which converts a .csv file to html nicely. Trying to add 3 colors, green, yellow and red to the output depending upon the values in the cells. Tried some printf command but just can't seem to get any where. Any ideas would be appreciated. nawk 'BEGIN{ FS="," print ... (7 Replies)
Discussion started by: jimmyf
7 Replies

2. UNIX for Dummies Questions & Answers

How to add '--color' with pipes?

Hi guys - I was wondering if there is a way to add 'color' to a grep I do like this below: fgrep -i "XYZ-1124354-P" mylog.log | tr "\001" " " | sed G (7 Replies)
Discussion started by: DallasT
7 Replies

3. Shell Programming and Scripting

Add color in CSV cells

hi, i have text file that file contains below information. Name,Roll,Mark,Total Sivasankar,2120,89,410 Raja,2212,87,425 i need to convert text file to CSV file also the heading(Name,Roll,Mark,Total) font should be BOLD and color should be RED. how can i set fonts in csv (5 Replies)
Discussion started by: rsivasan
5 Replies

4. UNIX for Dummies Questions & Answers

Grep ruins color

When I run: git branch -a I git a nice green and red colored output, but if I pipe the above command through grep: git branch -a | grep -v "master" I lose my colored output. Is there a way around this? (2 Replies)
Discussion started by: blasto333
2 Replies

5. UNIX for Dummies Questions & Answers

color highlighting with 'more','grep' and 'vi'

Hi all, i would to find out how can i turn on color hightlighting with the 'more' command. When i view a big file, i tend to use the 'more' command and i would search for a interested string with the '/' command. Something the search returns more than 1 line found on the screen, how can i... (0 Replies)
Discussion started by: new2ss
0 Replies
Login or Register to Ask a Question