find the first instance after a string
I have this file (below) and need to get out specific data that appears after OSE1_1.FIX, but before OSE1_2.FIX.
Specifically I need to get all of the data after "ROW80_20:", "ROW80_21:", "ROW80_22:" & "ROW80_23:" then I need to do the same for data the appears after OSE1_2.FIX, but before OSE1_3.FIX. (again for the same ROW80_XX).
I then need to format the data so that it stays in the same rows as it has appeared in the file i.e.
file ...
Received DF_STATUS,item = OSE1_1.FIX dataFormat = 2, item =
ROW80_16: Port 2 message rate 0 0
ROW80_6:
ROW80_20:Clients: xtky2143pmd xtky2140pmd xtky2141pmd 127.60.194.1
ROW80_21: Username:mdh_ai1p2_dma mdh_tk3p1_dma mdh_tk3p2_dma tk3d_ose1
ROW80_11: Line Handler Info LHOSERDT LHFIXRDT
ROW80_22: Watchlist: 4 6 10 55
ROW80_12: Uptime 002d05h17m 002d05h17m
ROW80_23: Max watch: 30 0 12 80
Received DF_STATUS, item = OSE1_2.FIX
ROW80_16: Port 2 message rate
ROW80_6:
ROW80_20: Clients: 127.60.194.1
ROW80_10:
ROW80_21: Username: rmds1
ROW80_22: Watchlist: 45
ROW80_12: Uptime
ROW80_23: Max watch: 60
Received DF_STATUS, item = OSE1_3.FIX
required output ...
Clients: , xtky2143pmd , xtky2140pmd , xtky2141pmd , 127.60.194.1 , 127.60.194.1
Username:, mdh_ai1p2_dma , mdh_tk3p1_dma , mdh_tk3p2_dma , tk3d_ose1 , rmds1
Watchlist:, 4 , 6 , 10 , 55 , 45
Max_watch:,30 , 0 , 12 , 80 , 60
(NOTE: My existing output from this script
cat $MY_FILE | grep ROW80_20: | head -2 |awk '{print $2 "," $3 "," $4 "," $5 "," $6 "," $7 "," $8}' > $MY_CLIENTS
cat $MY_FILE | grep ROW80_21: | head -2 |awk '{print $2 "," $3 "," $4 "," $5 "," $6 "," $7 "," $8}' >> $MY_CLIENTS
cat $MY_FILE | grep ROW80_22: | head -2 |awk '{print $2 "," $3 "," $4 "," $5 "," $6 "," $7 "," $8}' >> $MY_CLIENTS
cat $MY_FILE | grep ROW80_23: | head -2 |awk '{print $2 " " $3 "," $4 "," $5 "," $6 "," $7 "," $8}' >> $MY_CLIENTS
is....
Clients:,xtky2143pmd,xtky2140pmd,xtky2141pmd,147.60.194.1,,
Clients:,147.60.194.1,,,,,
Username:,mdh_ai1p2_dma,mdh_tk3p1_dma,mdh_tk3p2_dma,tk3d_ose1,,
Username:,rmds1,,,,,
Watchlist:,4,6,10,55,,
Watchlist:,45,,,,,
Max watch:,30,0,12,80,
Max watch:,60,,,,
Many thanks for all your help!!