I have a text file named compare.txt where I want to extract the single line that follows every line that contains the pattern nmse_gain_constant.
Well, the A switch by default will add those characters, so it's no mystery.
man grep states:
-A NUM
Places a line containing a group separator (--) between
contiguous groups of matches. With the -o or --only-matching
option, this has no effect and a warning is given.
But you can use a simple sed to clean up the result:
yourgrep | sed '/^--$/d'