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 Commented Sep 29, 2015 at 8:15

1 Answer 1

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. 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.