i have file below content example
cat test.log hello how you? terminating 1 2 3 terminating 1 2
when using grep command show output after terminating showing below.
sed -n '/terminating/,$p' test.log terminating 1 2 3 terminating 1 2
i want output below
terminating 1 2
can me on please?
code sed:
$ sed -n '/terminating/{n;n;h};${g;p}' file terminating 1 2
if line matches terminating
, store , next 2 lines in hold space. print 3 lines on $eof
.
example sed
script:
$ cat script.sed /terminating/{ n n h } ${ g p } $ sed -nf script.sed file terminating 1 2
and lines after last terminating
:
$ cat file cat test.log hello how you? terminating 1 2 3 terminating 1 2 3 4 5 6 $ cat script.sed h /terminating/{ h } ${ g p } $ sed -nf script.sed file terminating 1 2 3 4 5 6
Comments
Post a Comment