Reputation: 355
I have a file containing these lines:
some junk
in here
log number 1
line1, data, here
line2,data,here
line3,data,here
and so on
some other
junk
log number 2
line one, some,data
line two, some,data
line three, blablabla
I want to match and print about hundred lines after n-th match of log number ...
lines.
this solution works, but I don't want to type a 100 Ns in my sed command.
Also /log.*\n(.*\n){2}/gm
(printing 2 lines after match) works on regex101 but not on my terminal (sed doesn't match \n
).
I use arch linux and GNU sed version 4.8.
Upvotes: 0
Views: 2590
Reputation: 11227
Does something like this not work?
$ sed -n '/log.*1/,+4p' file
log number 1
line1, data, here
line2,data,here
line3,data,here
and so on
If you just need to print 100 lines after the match, it should be all you need.
$ sed -n '/log.*1/,+100p' file
Upvotes: 1