Is there a way I can build a regular expression (for grep) that will give me not only the line that matches it, but also one line before and after?
You don’t need to futz with the RE, the -A and -B options to grep do what you want, show you a specified number of lines after and before the matching line respectively.
OK, that works. Is there an option to turn off the “–” that grep adds between the matches, other than the obvious “grep -A 1 -B 1 -e ‘*A/’ < infile | sed ‘/^–$/d’”?
Seems as good a solution as any. BTW, you don’t need < infile, just infile will do.