Hello Guys, please help me. I'm an awk begginner whit this problem:
I have a large file like this:
DSV1 UWI: 3060000134 Depth: Conf. Factor:
DSV2 Common: K1292
DSV3 Survey Name: DevSurvey Method:
DSV4 Company: UNKNOWN Date:
DSV5 Remarks:
DSV6 Measr. Depth Deviation Direction
DSV7 0.0000 0.0000 180.0000
DSV7 30.0000 0.5000 196.7200
DSV7 60.0000 0.5000 349.6000
DSV1 UWI: 3060000134 Depth: Conf. Factor:
DSV2 Common: K1292
DSV3 Survey Name: Nuevos_Dir_Nov04 Method:
DSV4 Company: UNKNOWN Date:
DSV5 Remarks:
DSV6 Measr. Depth Deviation Direction
DSV7 0.0000 0.0000 0.0000
DSV7 0.0001 0.0000 0.0000
DSV7 51.0000 0.1200 170.4900
DSV7 81.0000 0.0900 188.6600
DSV7 111.0000 0.0700 128.3600
DSV7 141.0000 0.4300 263.2100
DSV7 171.0000 0.6200 102.3500
DSV1 UWI: 3060000988 Depth: Conf. Factor:
DSV2 Common: K1296
DSV3 Survey Name: RMA_21.84_13102010 Method:
DSV4 Company: UNKNOWN Date:
DSV5 Remarks:
DSV6 Measr. Depth Deviation Direction
DSV7 0.0000 0.0000 0.0000
DSV7 30.0000 0.5000 196.7200
DSV7 60.0000 0.5000 348.4000
which I need to separate into several files. The file name will be taken
from the record DSV2, but if the name is repeated then the filename should
have a different name. The delimiters are DSV1 and DSV7(which repeats).
Desired output:
Filename: K1292.dat
DSV1 UWI: 3060000500 Depth: Conf. Factor:
DSV2 Common: K1292
DSV3 Survey Name: DevSurvey Method:
DSV4 Company: UNKNOWN Date:
DSV5 Remarks:
DSV6 Measr. Depth Deviation Direction
DSV7 0.0000 0.0000 180.0000
DSV7 30.0000 0.5000 196.7200
DSV7 60.0000 0.5000 349.6000
Filename: K1292_v2.dat
DSV1 UWI: 3060000134 Depth: Conf. Factor:
DSV2 Common: K1292
DSV3 Survey Name: Nuevos_Dir_Nov04 Method:
DSV4 Company: UNKNOWN Date:
DSV5 Remarks:
DSV6 Measr. Depth Deviation Direction
DSV7 0.0000 0.0000 0.0000
DSV7 0.0001 0.0000 0.0000
DSV7 51.0000 0.1200 170.4900
DSV7 81.0000 0.0900 188.6600
DSV7 111.0000 0.0700 128.3600
DSV7 141.0000 0.4300 263.2100
DSV7 171.0000 0.6200 102.3500
Filename: K1296.dat
DSV1 UWI: 3060000988 Depth: Conf. Factor:
DSV2 Common: K1296
DSV3 Survey Name: RMA_21.84_13102010 Method:
DSV4 Company: UNKNOWN Date:
DSV5 Remarks:
DSV6 Measr. Depth Deviation Direction
DSV7 0.0000 0.0000 0.0000
DSV7 30.0000 0.5000 196.7200
DSV7 60.0000 0.5000 348.4000
I'm starting with:
awk '/DSV1/,/DSV7/{
if ($1 ~ /DSV2/ )
but I don't know how to hande repeated values of DSV7.
Thanks in advance Guys.
I have a large file like this:
DSV1 UWI: 3060000134 Depth: Conf. Factor:
DSV2 Common: K1292
DSV3 Survey Name: DevSurvey Method:
DSV4 Company: UNKNOWN Date:
DSV5 Remarks:
DSV6 Measr. Depth Deviation Direction
DSV7 0.0000 0.0000 180.0000
DSV7 30.0000 0.5000 196.7200
DSV7 60.0000 0.5000 349.6000
DSV1 UWI: 3060000134 Depth: Conf. Factor:
DSV2 Common: K1292
DSV3 Survey Name: Nuevos_Dir_Nov04 Method:
DSV4 Company: UNKNOWN Date:
DSV5 Remarks:
DSV6 Measr. Depth Deviation Direction
DSV7 0.0000 0.0000 0.0000
DSV7 0.0001 0.0000 0.0000
DSV7 51.0000 0.1200 170.4900
DSV7 81.0000 0.0900 188.6600
DSV7 111.0000 0.0700 128.3600
DSV7 141.0000 0.4300 263.2100
DSV7 171.0000 0.6200 102.3500
DSV1 UWI: 3060000988 Depth: Conf. Factor:
DSV2 Common: K1296
DSV3 Survey Name: RMA_21.84_13102010 Method:
DSV4 Company: UNKNOWN Date:
DSV5 Remarks:
DSV6 Measr. Depth Deviation Direction
DSV7 0.0000 0.0000 0.0000
DSV7 30.0000 0.5000 196.7200
DSV7 60.0000 0.5000 348.4000
which I need to separate into several files. The file name will be taken
from the record DSV2, but if the name is repeated then the filename should
have a different name. The delimiters are DSV1 and DSV7(which repeats).
Desired output:
Filename: K1292.dat
DSV1 UWI: 3060000500 Depth: Conf. Factor:
DSV2 Common: K1292
DSV3 Survey Name: DevSurvey Method:
DSV4 Company: UNKNOWN Date:
DSV5 Remarks:
DSV6 Measr. Depth Deviation Direction
DSV7 0.0000 0.0000 180.0000
DSV7 30.0000 0.5000 196.7200
DSV7 60.0000 0.5000 349.6000
Filename: K1292_v2.dat
DSV1 UWI: 3060000134 Depth: Conf. Factor:
DSV2 Common: K1292
DSV3 Survey Name: Nuevos_Dir_Nov04 Method:
DSV4 Company: UNKNOWN Date:
DSV5 Remarks:
DSV6 Measr. Depth Deviation Direction
DSV7 0.0000 0.0000 0.0000
DSV7 0.0001 0.0000 0.0000
DSV7 51.0000 0.1200 170.4900
DSV7 81.0000 0.0900 188.6600
DSV7 111.0000 0.0700 128.3600
DSV7 141.0000 0.4300 263.2100
DSV7 171.0000 0.6200 102.3500
Filename: K1296.dat
DSV1 UWI: 3060000988 Depth: Conf. Factor:
DSV2 Common: K1296
DSV3 Survey Name: RMA_21.84_13102010 Method:
DSV4 Company: UNKNOWN Date:
DSV5 Remarks:
DSV6 Measr. Depth Deviation Direction
DSV7 0.0000 0.0000 0.0000
DSV7 30.0000 0.5000 196.7200
DSV7 60.0000 0.5000 348.4000
I'm starting with:
awk '/DSV1/,/DSV7/{
if ($1 ~ /DSV2/ )
but I don't know how to hande repeated values of DSV7.
Thanks in advance Guys.