removing pattern which is spread in multiple lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting removing pattern which is spread in multiple lines
# 1  
Old 05-12-2008
Error removing pattern which is spread in multiple lines

I have several huge files wich contains oracle table creation scripts as follows:
Quote:
CREATE TABLE PROD_MST.PROD_DEF_ALLOWED_RESELLERS (
PROD_DEF_ALLOWED_RESELR_ID NUMBER NOT NULL,
SRVC_PROVIDER_ID NUMBER NOT NULL,
CREATED_BY VARCHAR2(40 BYTE) NOT NULL,
CREATED_DTIME DATE NOT NULL,
LAST_UPDATED_BY VARCHAR2(40 BYTE) NOT NULL,
LAST_UPDATED_DTIME DATE NOT NULL,
PROD_ID NUMBER NOT NULL
)
PCTFREE 10
PCTUSED 0
INITRANS 1
MAXTRANS 255

TABLESPACE CUST_MASTER_DATA
STORAGE (
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
)
LOGGING

;


CREATE TABLE PROD_MST.PROD_DEFINITION (
PROD_ID NUMBER NOT NULL,
PROD_NAME VARCHAR2(100 BYTE) NULL,
PROD_STATUS VARCHAR2(20 BYTE) NULL,
PROD_CODE VARCHAR2(40 BYTE) NULL,
PROD_CODE_TYPE VARCHAR2(40 BYTE) NULL,
PROD_EFFECTIVE_START_DATE DATE NULL,
PROD_EFFECTIVE_END_DATE DATE NULL,
SRVC_PROVIDER_ID NUMBER NOT NULL,
CREATED_BY VARCHAR2(40 BYTE) NOT NULL,
CREATED_DTIME DATE NOT NULL,
LAST_UPDATED_BY VARCHAR2(40 BYTE) NOT NULL,
LAST_UPDATED_DTIME DATE NOT NULL
)
PCTFREE 10
PCTUSED 0
INITRANS 1
MAXTRANS 255

TABLESPACE PROD_MASTER_DATA
STORAGE (
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
)
LOGGING

;
.....
and so on
I would need to remove the pattern colored in red above. Any sed/awk/pearl code will be of much help.

Thanks
# 2  
Old 05-12-2008
Code:
perl -i.bck -073 -pe's/PCTFREE.*?(TABLESPACE.*?\n).*?;/$1;/s' file

# 3  
Old 05-13-2008
MySQL

Worked absolutely fine. Thanks a ton!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Remove newline character from column spread over multiple lines in a file

Hi, I came across one issue recently where output from one of the columns of the table from where i am creating input file has newline characters hence, record in the file is spread over multiple lines. Fields in the file are separated by pipe (|) delimiter. As header will never have newline... (4 Replies)
Discussion started by: Prathmesh
4 Replies

2. Shell Programming and Scripting

Removing carriage returns from multiple lines in multiple files of different number of columns

Hello Gurus, I have a multiple pipe separated files which have records going over multiple Lines. End of line separator is \n and records going over multiple lines have <CR> as separator. below is example from one file. 1|ABC DEF|100|10 2|PQ RS T|200|20 3| UVWXYZ|300|30 4| GHIJKL|400|40... (7 Replies)
Discussion started by: dJHa
7 Replies

3. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

GM, I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed. I am assuming that sed, awk or even perl could do what I need. I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies

4. Shell Programming and Scripting

Match Pattern and print pattern and multiple lines into one line

Hello Experts , require help . See below output: File inputs ------------------------------------------ Server Host = mike id rl images allocated last updated density vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies

5. UNIX for Dummies Questions & Answers

Removing PATTERN from txt without removing lines and general text formatting

Hi Everybody! First post! Totally noobie. I'm using the terminal to read a poorly formatted book. The text file contains, in the middle of paragraphs, hyphenation to split words that are supposed to be on multiple pages. It looks ve -- ry much like this. I was hoping to use grep -v " -- "... (5 Replies)
Discussion started by: AxeHandle
5 Replies

6. Shell Programming and Scripting

[AWK] handeling data spread on multiple lines

Hello all, first off great forum. Now for my little problem. Using RHEL 5.4 and awk. Been doing code since a few month. So just starting. My problem is handeling data on multiple lines. { if ($1 != LASTKEY && h ~ /.*\/s_fr_/) { checkgecos( h, h ) h="" ... (2 Replies)
Discussion started by: maverick72
2 Replies

7. Shell Programming and Scripting

Removing all lines prior to the last pattern in a file/stream

Hi all, I didn't find anything that specifically answers this after searching for a bit, so please forgive me if this has been covered before. I'm looking to delete all lines prior to the last occurrence of a string in a file or stream from within a shell script (bash.) A bit of... (4 Replies)
Discussion started by: LivinFree
4 Replies

8. Shell Programming and Scripting

Removing multiple lines but not the next attribute

I'm hitting a brick wall, I have huge ldif files that I'm trying to sanitize and can do it all with SED except one thing. I have a publicKey attribute in binary that can be one line or multiple lines. I'm trying to remove publicKey: and stop at sn (the next attribute). Even with word Wrap... (3 Replies)
Discussion started by: LCol
3 Replies

9. Shell Programming and Scripting

removing lines around a matched pattern

I have an ugly conf file that has the string I'm interested in searching for in the middle of a block of code that's relevant, and I'm trying to find a way to remove that entire block based on the matched line. I've googled for this problem, and most people helping are only interested in... (9 Replies)
Discussion started by: tamale
9 Replies

10. UNIX for Dummies Questions & Answers

Can I spread commands over multiple lines?

Below an example of what I mean. The first attempt does what I want; the second doesn't, because bash assumes a line break means the end of an individual "command unix". Is there some way that I can convince bash to parse out, eg, to the closing parenthesis? I'm thinking this would allow for... (1 Reply)
Discussion started by: tphyahoo
1 Replies
Login or Register to Ask a Question