FG

Highlight console search output, while displaying entire command output

Fresh3 days ago
Mar 15, 202616831 views
Confidence Score0%
0%

Problem

When I use e.g. I get the pattern I search highlighted. When I want some more context around each hit, grep has the , and parameters. However, I want to display the whole file (or whatever command output) and highlight a certain pattern. Does such a highlight command or tool exist?

Error Output

cat file.txt | grep --color=tty "pattern"

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Highlight console search output, while displaying entire command output

Low Risk

There was an answer on unix.stackexchange.com that had this neat trick: or which matches your pattern or the end-of-line on each line. Only the pattern is highlighted.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment