Eg:CREATE TABLE COMM.ACL_ENTRY (        ACL_OID CHAR(18) FOR BIT DATA NOT NULL ,        USER_DESC_TYPE FOR COLUMN USER_00001 BIGINT NOT NULL ,        USER_DESC_OID FOR COLUMN USER_00002 VARGRAPHIC(220) CCSID 13488 NOT NULL ,        ACTIONS BIGINT NOT NULL ,        CONSTRAINT COMM.PK5111 PRIMARY KEY( ACL_OID , USER_DESC_OID ) )        ;ALTER TABLE COMMUN.ACL_ENTRY        ADD CONSTRAINT COMM.FK5111A        FOREIGN KEY( ACL_OID )        REFERENCES COMM.ACL ( OID )        ON DELETE CASCADE        ON UPDATE NO ACTION ;As you can see in the above example. I want to delete the lines that start with word ALTER till it ends with a specific pattern ; and print the deleted lines in another file.
How to delete the lines that starts with a specific word and end with a specific word
shell script;text processing;sed;awk;sql
You can use sed for both the tasks. It supports so called addresses, which could be regular expressions:sed -n -e '/^ALTER/,/;$/p' > another.file # Prints them,sed -i~ -e '/^ALTER/,/;$/d'               # Deletes them.