How can I use the grep --color command to highlight brackets?
I want to highlight every [
in any color so i can see the hidden message here:
[###[#[[[#[###[#[[[#[[[#[###[#[[[
[###[##[##[[##[#[####[##[[##[##[#
[######[##[#[#[#[[[##[##[#[#[##[#
[######[##[##[[#[####[##[##[[##[#
[[[###[[[#[###[#[###[[[#[###[#[[[
You want to match [
but, in grep
, [
is a regex active character. The solution is to escape it with a backslash so that grep
will treat it as a plain simple literal character:
grep --color=always '\[' fname
The output looks like: