So I'm trying to show the contents of a text file with every occurrence of a particular word that is highlighted. I don't want to use grep as that only shows the sentences with that word in. I want to use the cat command.
Asked
Active
Viewed 575 times
-2
-
1Why do you want to do this ? – Garf365 May 09 '16 at 08:37
-
Where are the words highlighted? – Walter A May 09 '16 at 08:55
2 Answers
0
I still suggest you use the grep
command, and specify a big context value to print out lines "near" the matching lines, e.g:
grep -C 999999999 needle haystack

jotik
- 17,044
- 13
- 58
- 123
0
Following will print whole file, and color only the matching text
grep --color -E "PATTERN|$" data

P....
- 17,421
- 2
- 32
- 52