I need to search the strings in a text file that has the following information:
INSERT INTO TEST123
values (1,2,3);
INSERT INTO ABCD
values (1,2,3);
UPDATE TEST123
SET
ABC='123'
WHERE ABC='124';
UPDATE ABCD
SET
ABC='123'
WHERE ABC='124';
DELETE FROM TEST123
WHERE ABC = '111'
AND DEF= '222'
AND GHI='333';
DELETE FROM ABCD
WHERE ABC = '111'
AND DEF= '222'
AND GHI='333';
How could I Search for the string "TEST123" and then search for the following character ";".
Once these two strings are found, I want to Copy the data from line1(FIRST STRING FOUND) and lineN(SECOND STRING FOUND) to another file..
NEW FILE OUTPUT:
INSERT INTO TEST123
values (1,2,3);
UPDATE TEST123
SET
ABC='123'
WHERE ABC='124';
DELETE FROM TEST123
WHERE ABC = '111'
AND DEF= '222'
AND GHI='333';
Any help is appreciated