Is there a
grep -like command to highlight specific text in a command's output, but shows all lines irrespective of the presence of the desired text and allows one to interact with the piped(1) or monitored(2) command?
command | highlightThisText 'string1' 'string2' 'string3'
- as in how the
timecommand works to time a command, e.g.
time echo foo
My scenario is as such.:
I have a server with Ubuntu Server 14.04.2 which needs an HP driver specific to the kernel shipped with 14.04.2. I can't do
apt-get update ; apt-get upgrade willy-nilly because a kernel update could hose the OS's ability to access the RAID controller. I'm doing
apt-get --only-upgrade install packagename to upgrade existing packages one at a time. At a minimum, I'd like
- "Suggested packages:"
- "The following packages will be upgraded:"
- "The following extra packages will be installed:"
to be highlighted like a
grep statement would, but I also need to interact with the prompts. The highlighting would make it faster to visually pick out which packages are being fetched.
As I was finalizing this post, I was choosing tags and came across
source-highlight. This seems close, but it looks that only produces highlighted output documents, not in-terminal colorized output.
Someone commented (but apparently deleted) this post Convince grep to output all lines, not just those with matches may be what I'm looking for. It's very close to fitting my needs - specifically piping into
grep -E --color "Things I'd like highlighted" - but when I get to a portion where
apt-get prompts me to continue "[Y/n]", it doesn't display anything. At that point, I know to press 'Y' or 'n', but if I wanted to use this for other commands, I may not know what to press if
grep is blocking the prompt.
As an example, below I'm using
read is waiting for input and doesn't colorize, but
echo displays as it should.