rhnaeco
Technical User
- Aug 11, 2005
- 45
hi, i have a data set of sonar pings. Each record consists of several lines of associate data such as depth and position and followed by 30 lines of actual data, followed by the next record.
normally i would say something like ' if $1 = "line1" then print next 30 lines' and then sort it out further from there.
In this case the only characters which consistantly appear are the letters BT on line 6, but i need info in the preceeding lines and followng lines; does anyone know how i would get awk to do this?:
find 'BT', print $2, $3, $4 of line -4 (line 2 for first record), print $1, $2 of line -2 (line 4)and print this as teh first 5 strings of every following data line (lines 7-30 for the first record), and then start again with the next instance of BT.
input (bracket numbers added for clarity):
1)485 1 0.900 -0.160 184.390 21.070
2)0.00 3.30 3.43 3.30
3)0.00 0.00 0.00 0.00
4)45.4257217 12.4309501 10.60
5)0.0 0.0 0.0 0.0
6)30 cm BT dB 0.43 0.156
7) 1.47 8.48 37.82 5.2 6.7 -8.6 -32768
8) 1.97 20.54 81.32 20.3 3.1 -7.1 -32768
9) 2.47 23.37 94.42 23.3 -1.8 -6.2 -32768
10) 2.97 12.82 3.58 0.8 12.8 -9.5 -32768
output:
1) 3.30 3.43 3.3 45.4257217 12.4309501 1.47 8.48 37.82 5.2 6.7 -8.6 -32768
2) 3.30 3.43 3.3 45.4257217 12.4309501 1.97 20.54 81.32 20.3 3.1 -7.1 -32768
hope this makes sense and really hope someone can help, or at least help to extract the lines which i need.
thanks in advance
rhnaeco
normally i would say something like ' if $1 = "line1" then print next 30 lines' and then sort it out further from there.
In this case the only characters which consistantly appear are the letters BT on line 6, but i need info in the preceeding lines and followng lines; does anyone know how i would get awk to do this?:
find 'BT', print $2, $3, $4 of line -4 (line 2 for first record), print $1, $2 of line -2 (line 4)and print this as teh first 5 strings of every following data line (lines 7-30 for the first record), and then start again with the next instance of BT.
input (bracket numbers added for clarity):
1)485 1 0.900 -0.160 184.390 21.070
2)0.00 3.30 3.43 3.30
3)0.00 0.00 0.00 0.00
4)45.4257217 12.4309501 10.60
5)0.0 0.0 0.0 0.0
6)30 cm BT dB 0.43 0.156
7) 1.47 8.48 37.82 5.2 6.7 -8.6 -32768
8) 1.97 20.54 81.32 20.3 3.1 -7.1 -32768
9) 2.47 23.37 94.42 23.3 -1.8 -6.2 -32768
10) 2.97 12.82 3.58 0.8 12.8 -9.5 -32768
output:
1) 3.30 3.43 3.3 45.4257217 12.4309501 1.47 8.48 37.82 5.2 6.7 -8.6 -32768
2) 3.30 3.43 3.3 45.4257217 12.4309501 1.97 20.54 81.32 20.3 3.1 -7.1 -32768
hope this makes sense and really hope someone can help, or at least help to extract the lines which i need.
thanks in advance
rhnaeco