How to highlight a word in a text file

written by Admin

Posted on 2013-09-03


I want to highlight a word in a text file without removing other lines (like using grep).


You can use egrep to highlight text - or what you want, using regular expressions - but after the search term you must put a pipe to leave all lines (also those non highlighted) in the output:
# egrep --color 'word|' file.txt



Leave a Comment:



We need collaboration and a real boost from our community: write us an email for every trick you find!

This website is a sysadmin swiss-knife for every-day Windows, Linux and Mac administration and troubleshooting

Our database grows if YOU send us your tips and trick as soon as you find them every day!