finding surrounding lines with grep
By Mia Morrison •
I know how to use grep to output a line that matches a string. But what if I also want to output one line above every line containing a matching string, how do I do that?
1 Answer
do the following
grep -B 1 text_to_search_for file.txt 2 More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"