Quantcast
Channel: User Kamil Maciorowski - Super User
Viewing all articles
Browse latest Browse all 645

Comment by Kamil Maciorowski on print (only) line preceding a match

$
0
0
@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.

Viewing all articles
Browse latest Browse all 645

Trending Articles