0

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.

1
  • Format your question – 123 Sep 29 '15 at 8:15
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.