@umläute For the record: my
sed
solution is multi-line for readability, it can as well be sed -n 'N;/\n.*pattern/P;D'
. I don't mind my answer not being accepted, I'm just noticing that: (1) Being a one-liner is usually just about the form, as you can often fit even relatively complex script in one line. (2) Nowhere in the question there is any information that you prefer a one-liner. (3) There is the requirement that "the solution should run in a POSIX shell, with only standard tools installed (not even Python!)". sed
and awk
are in the POSIX standard; perl
(like python
!) is not.