Hey all, newbie to awk here.
I'm trying to write an awk command that will split test out of a larger file and put it into smaller files based on start and stop sequences. I'm running into the system limitation of 10 files open and can't get the close() command to work. Any help is appreciated.
The source file is:
11111111111111 dont want
11111111111112 start.*101-01
11111111111113 file 1 text
11111111111114 stop
11111111111115 dont want
11111111111116 start.*101-02
11111111111117 file 2 text
11111111111118 stop
11111111111119 dont want
11111111111120 start.*101-03
11111111111121 file 3 text
11111111111122 stop
11111111111123 dont want
11111111111124 start.*102-01
11111111111125 file 4 text
11111111111126 stop
11111111111127 dont want
11111111111128 start.*102-02
11111111111129 file 5 text
11111111111130 stop
11111111111131 dont want
11111111111132 start.*102-03
11111111111133 file 6 text
11111111111134 stop
11111111111135 dont want
11111111111136 start.*102-04
11111111111137 file 7 text
11111111111138 stop
11111111111139 dont want
11111111111140 start.*102-05
11111111111141 file 8 text
11111111111142 stop
11111111111143 dont want
11111111111144 start.*103-01
11111111111145 file 9 text
11111111111146 stop
11111111111147 dont want
11111111111148 start.*103-02
11111111111149 file 10 text
11111111111150 stop
11111111111151 dont want
11111111111152 start.*103-03
11111111111153 file 11 text
11111111111154 stop
.
.
.
.
.
.
My awk file is:
awk '
BEGIN{{prefix=100}}
/start/,/stop/ {{file = "test" prefix}{print >> file}{close(file)}}
/stop/ {{++prefix}}
' source
---------
This file is to take everything between "Start" and "Stop" and save it in a file called "test1##" for each case.
Any help is greatly appreciated!
Scott
I'm trying to write an awk command that will split test out of a larger file and put it into smaller files based on start and stop sequences. I'm running into the system limitation of 10 files open and can't get the close() command to work. Any help is appreciated.
The source file is:
11111111111111 dont want
11111111111112 start.*101-01
11111111111113 file 1 text
11111111111114 stop
11111111111115 dont want
11111111111116 start.*101-02
11111111111117 file 2 text
11111111111118 stop
11111111111119 dont want
11111111111120 start.*101-03
11111111111121 file 3 text
11111111111122 stop
11111111111123 dont want
11111111111124 start.*102-01
11111111111125 file 4 text
11111111111126 stop
11111111111127 dont want
11111111111128 start.*102-02
11111111111129 file 5 text
11111111111130 stop
11111111111131 dont want
11111111111132 start.*102-03
11111111111133 file 6 text
11111111111134 stop
11111111111135 dont want
11111111111136 start.*102-04
11111111111137 file 7 text
11111111111138 stop
11111111111139 dont want
11111111111140 start.*102-05
11111111111141 file 8 text
11111111111142 stop
11111111111143 dont want
11111111111144 start.*103-01
11111111111145 file 9 text
11111111111146 stop
11111111111147 dont want
11111111111148 start.*103-02
11111111111149 file 10 text
11111111111150 stop
11111111111151 dont want
11111111111152 start.*103-03
11111111111153 file 11 text
11111111111154 stop
.
.
.
.
.
.
My awk file is:
awk '
BEGIN{{prefix=100}}
/start/,/stop/ {{file = "test" prefix}{print >> file}{close(file)}}
/stop/ {{++prefix}}
' source
---------
This file is to take everything between "Start" and "Stop" and save it in a file called "test1##" for each case.
Any help is greatly appreciated!
Scott