I have a header-detail file that goes like this:
SHP00288820131021110921
ORDER0156605920131021110921INMMMMFN
DETAIL0004 4C2Z 10769 AAFC 0000009600000094 4C2Z 10769 AAFC 0000672107 OIL
DETAIL0002 ER3Z 14300 E 0000001300000012 ER3Z 14300 E 0000672107 OIL
DETAIL0003 MBXT 58 R 0000004600000045 MBXT 58 R 0000672107 OIL
ORDER0156605820131021110921NIMMMMFN
DETAIL0001 4C4Z 10753 GA 0000007800000078 4C4Z 10753 GA 0000672108 OIL
The objective is to delete from the file ORDER number 01566058 a it's detail DETAIL0001 because order's layout is wrong and I do not want to keep it.
I've been googling but run out of ideas. Any help would be appreciated.
Some more complete input data, and the output you'd want from it, would be helpful. This is a bit ambiguous as is.
Try:
awk '/ORDER01566058/{getline;next}1' file
That's exactly what i was looking for. Thanks bartus11. Talking about number 1 it could be variable, example.
ORDER0163069420130712102624BOAF52M000031473004790
DETAIL0003 9L1Z 7861202AC 0000000100000001 9L1Z 7861202AC 0000669478
ORDER0164796720130711114537INCWB6A
DETAIL0002 MAB39 16451JC 0000000100000001 MAB39 16451JC 00006692200012444329
DETAIL0001 MAB39 16450JC 0000000100000001 MAB39 16450JC 00006692200012444330
ORDER0165218120130711175459INCWB6A
DETAIL0004 1215876 0000000300000003 1215876 00006695690012445135
DETAIL0005 MAB39 12B637AG 0000031500000099 MAB39 12B637AG 00006692710012443789
DETAIL0015 MCE83 5464811BB 0000001000000001 MBE8Z 5464811B 00006692710012443785
DETAIL0001 M95SY15010974AB 0000000100000001 M95SY15010974AB 00006697540012447141
DETAIL0002 M95SY15010974AB 0000000100000001 M95SY15010974AB 00006697890012445414
ORDER0165647120130712120945BOAF52M000039493001759
DETAIL0002 AT4Z 6333A 0000000400000002 AT4Z 6333A 0000669461
DETAIL0001 M6L55 6B032AA 0000000200000002 M6L55 6B032AA 00006692960012444260
ORDER0166048820130712114708BOCWB6A
DETAIL0001 M8L55 5K214EC 0000000100000001 M8L55 5K214EC 00006694640012445152
ORDER0166074720130712102954BOAF52M000031473011149
DETAIL0001 DB5Z 9A407A 0000000100000001 DB5Z 9A407A 0000669459
As referred before orders could have N details and i have to determine how many lines should be deleted with the command. Is there's a way to index the file. I mean:
ORDER01630694 has DETAIL0003. (1)
ORDER01647967 has DETAIL0001 and DETAIL0002. (2)
ORDER01652181 has DETAIL0004, DETAIL0005, DETAIL0005, DETAIL0005 and DETAIL0002. (5)
and so on.
In that way could be easier to know the number lines that should be omitted.
awk '/ORDER01566058/{getline;next}N' file
Thanks in advanced.