In bash, if I want to execute a command and only display output lines that matches a certain pattern, I can pipe it to grep
, like
file testfile
hello
there
my
friends
command
$ cat testfile | grep 'hello'
hello #this will be highlightd
this will highlight the search match and display the entire line it falls on. I can use -A
and -B
to display lines before and after that line. My question is is it possible to execute the command and display all output as normal, but to highlight the search matches like grep would? so my ouput would be
hello #highlighted
there
my
friends