How to easily print line above the match and skip the match itself? grep -A, -B and -o opt do not solve it. Maybe some
grep
-A
-B
-o
Just set p to the pattern you want:
p
$ awk '$0~p{print a}{a=$0}' p="foo" file bar baz foo