I've read several posts that handle syntax highlighting, cat
and grep
(like this one and this one too) but haven't yet found what I'm looking for. I want to print an entire text file to terminal, and have a specific (repeating) word colored in red. Lines that do not have this word should be printed out too. Here's something that comes close, but only
prints lines that contain the specific word. This post doesn't show it, but the load word is colored red like it should.
$ cat input.ll | grep "load"
%tmp = load %class.A*, %class.A** %p, align 8
%vtable = load i32 (%class.A*, i32, i32, i32)**, i32 (%class.A*, i32, i32, i32)*** %tmp1, align 8
%tmp2 = load i32 (%class.A*, i32, i32, i32)*, i32 (%class.A*, i32, i32, i32)** %vfn, align 8
%tmp3 = load i32, i32* @x, align 4
And here is the original file:
$ cat input.ll
%tmp = load %class.A*, %class.A** %p, align 8
%tmp1 = bitcast %class.A* %tmp to i32 (%class.A*, i32, i32, i32)***
%vtable = load i32 (%class.A*, i32, i32, i32)**, i32 (%class.A*, i32, i32, i32)*** %tmp1, align 8
%vfn = getelementptr inbounds i32 (%class.A*, i32, i32, i32)*, i32 (%class.A*, i32, i32, i32)** %vtable, i64 2
%tmp2 = load i32 (%class.A*, i32, i32, i32)*, i32 (%class.A*, i32, i32, i32)** %vfn, align 8
%tmp3 = load i32, i32* @x, align 4
%call = call i32 %tmp2(%class.A* %tmp, i32 3, i32 %tmp3, i32 7)