When using grep I would like to ignore DEBUG=, but not ignore DEBUG=-g, DEBUG=-g -misalign. I only care about DEBUG= if there is something after the equal sign =. Things I wanna see.
Yes. I need to get better at regex :). I am doing a double grep because I still want to pick up things like $(DEBUG), #With debug, DEBUG+=-g, #Without debug, #With debug, etc.
DEBUG=-g
Random stuff
DEBUG=
hi
DEBUG=-g -misalign
hi
echos
DEBUG=
boo
DEBUG=-misalign
stuff
DEBUG=-xmemalign=1i
tricky
DEBUG=
work
$(DEBUG)
#With debug
um
DEBUG=
running
DEBUG+=-g
out
#Without debug
of
DEBUG=
things
#With debug
to
DEBUG=
say
as it discards all the lines with immediate newline character after the equal sign (given that there is an equal sign in the line of text, and that it immediately follows the 'DEBUG')
Brain not thinking. The cat -vet is adding the newline $ character. Was just trying to add line numbers to make it more readable. Sorry about that.
This is what the data is supposed to be.
DEBUG=-g
Random stuff
DEBUG=
hi
DEBUG=-g -misalign
hi
echos
DEBUG=
boo
DEBUG=-misalign
stuff
DEBUG=-xmemalign=1i
tricky
DEBUG=
work
$(DEBUG)
#With debug
um
DEBUG=
running
DEBUG+=-g
out
#Without debug
of
DEBUG=
things
#With debug
to
DEBUG=
say
Yes, I think I got previously, what the input data is supposed to be
Now I'm trying to understand, what the desired output is supposed to be, after you filter input through double grep pipeline. See my previous reply.
Also wanna keep these $(DEBUG), #With debug, DEBUG+=-g, #Without debug, #With debug,. That is why I am trying to do it in two stages. First pick up all the debug. Then chop out DEBUG=.
So, I think this is exactly what I got in my reply few minutes earlier
Is this: grep -i 'debug' input.txt | grep -v 'DEBUG=$' the command line you're looking for? (when your file is named input.txt)