I have a large file that consists of many machine programs all together as one large txt file. I want to use sed to look for lines that start with an Oxxxx format like-
O00002 (A36 RETAINER ASSEMBLY .2495 HOLE OP 1)
(RUN OPTIONAL STOP TO MOVE COOLANT)
N2 (CD)
T9 M06
T3
G00 G90 G54 G43 H09 Z5. X0. Y0. S2000 M03
Z2. M08
I have tried the following and many variations-
sed -i.gap '/^O[0-9]{4,5}.*/i testtest \n' ALL.NC
I have tried every example I've seen and nothing works. Any pointers towards syntax also appreciated.
Thank you!
[0-9]\{4,5\}
– steeldriver Jul 19 '22 at 23:18sed -E
enables "extended" regular expressions (likegrep -E
):x{4,5}
is 4 or 5 x's andx\{4,5\}
is the character sequence "x { 4 , 5 }" – glenn jackman Jul 20 '22 at 01:07