Here's what I'm trying to do.
I'm printing a pattern out of a source file by matching it using:
nawk'
.
.
.
/start_string/,/stop_string/{print > output.file}
.
.
.
' input.file
Sample input.file
.
.
.
1111blah
1112blah
1113blah
1114header information 1
1115header information 2
1116blah blah start_string blah
1117recording
1118all
1119of
1120this
1121blah blah stop_string blah
1122footer information 1
1123footer information 2
1124blah
1125blah
1126blah
1127blah
.
.
.
Right now I'm getting an output.file that looks like:
1116blah blah start_string blah
1117recording
1118all
1119of
1120this
1121blah blah stop_string blah
I would like an output.file that looks like:
1114header information 1
1115header information 2
1116blah blah start_string blah
1117recording
1118all
1119of
1120this
1121blah blah stop_string blah
1122footer information 1
1123footer information 2
None of the header or footer information is unique enough to pattern directly and I was wondering if there is a way to call the pattern match and have it start/stop "n" lines (this case n=2) before/after the pattern is encountered.
Any hints to get me back on track?
Thanks in advance!
Scott
I'm printing a pattern out of a source file by matching it using:
nawk'
.
.
.
/start_string/,/stop_string/{print > output.file}
.
.
.
' input.file
Sample input.file
.
.
.
1111blah
1112blah
1113blah
1114header information 1
1115header information 2
1116blah blah start_string blah
1117recording
1118all
1119of
1120this
1121blah blah stop_string blah
1122footer information 1
1123footer information 2
1124blah
1125blah
1126blah
1127blah
.
.
.
Right now I'm getting an output.file that looks like:
1116blah blah start_string blah
1117recording
1118all
1119of
1120this
1121blah blah stop_string blah
I would like an output.file that looks like:
1114header information 1
1115header information 2
1116blah blah start_string blah
1117recording
1118all
1119of
1120this
1121blah blah stop_string blah
1122footer information 1
1123footer information 2
None of the header or footer information is unique enough to pattern directly and I was wondering if there is a way to call the pattern match and have it start/stop "n" lines (this case n=2) before/after the pattern is encountered.
Any hints to get me back on track?
Thanks in advance!
Scott