Sponsored Content
Top Forums Shell Programming and Scripting removing pattern which is spread in multiple lines Post 302194221 by sabyasm on Monday 12th of May 2008 01:16:11 PM
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
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
OCI_FETCH_OBJECT(3)													       OCI_FETCH_OBJECT(3)

oci_fetch_object - Returns the next row from a query as an object

SYNOPSIS
object oci_fetch_object (resource $statement) DESCRIPTION
Returns an object containing the next result-set row of a query. Each attribute of the object corresponds to a column of the row. This function is typically called in a loop until it returns FALSE, indicating no more rows exist. For details on the data type mapping performed by the OCI8 extension, see the datatypes supported by the driver PARAMETERS
o $statement -A valid OCI8 statement identifier created by oci_parse(3) and executed by oci_execute(3), or a REF CURSOR statement identifier. RETURN VALUES
Returns an object. Each attribute of the object corresponds to a column of the row. If there are no more rows in the $statement then FALSE is returned. Any LOB columns are returned as LOB descriptors. DATE columns are returned as strings formatted to the current date format. The default format can be changed with Oracle environment vari- ables such as NLS_LANG or by a previously executed ALTER SESSION SET NLS_DATE_FORMAT command. Oracle's default, non-case sensitive column names will have uppercase attribute names. Case-sensitive column names will have attribute names using the exact column case. Use var_dump(3) on the result object to verify the appropriate case for attribute access. Attribute values will be NULL for any NULL data fields. EXAMPLES
Example #1 oci_fetch_object(3) example <?php /* Before running, create the table: CREATE TABLE mytab (id NUMBER, description VARCHAR2(30)); INSERT INTO mytab (id, description) values (1, 'Fish and Chips'); COMMIT; */ $conn = oci_connect('hr', 'welcome', 'localhost/XE'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $stid = oci_parse($conn, 'SELECT id, description FROM mytab'); oci_execute($stid); while (($row = oci_fetch_object($stid)) != false) { // Use upper case attribute names for each standard Oracle column echo $row->ID . "<br> "; echo $row->DESCRIPTION . "<br> "; } // Output is: // 1 // Fish and Chips oci_free_statement($stid); oci_close($conn); ?> Example #2 oci_fetch_object(3) with case sensitive column names <?php /* Before running, create the table with a case sensitive column name: CREATE TABLE mytab (id NUMBER, "MyDescription" VARCHAR2(30)); INSERT INTO mytab (id, "MyDescription") values (1, 'Iced Coffee'); COMMIT; */ $conn = oci_connect('hr', 'welcome', 'localhost/XE'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $stid = oci_parse($conn, 'SELECT id, "MyDescription" FROM mytab'); oci_execute($stid); while (($row = oci_fetch_object($stid)) != false) { // Use upper case attribute names for each standard Oracle column echo $row->ID . "<br> "; // Use the exact case for the case sensitive column name echo $row->MyDescription . "<br> "; } // Output is: // 1 // Iced Coffee oci_free_statement($stid); oci_close($conn); ?> Example #3 oci_fetch_object(3) with LOBs <?php /* Before running, create the table: CREATE TABLE mytab (id NUMBER, description CLOB); INSERT INTO mytab (id, description) values (1, 'A very long string'); COMMIT; */ $conn = oci_connect('hr', 'welcome', 'localhost/XE'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $stid = oci_parse($conn, 'SELECT id, description FROM mytab'); oci_execute($stid); while (($row = oci_fetch_object($stid)) != false) { echo $row->ID . "<br> "; // The following will output the first 11 bytes from DESCRIPTION echo $row->DESCRIPTION->read(11) . "<br> "; } // Output is: // 1 // A very long oci_free_statement($stid); oci_close($conn); ?> SEE ALSO
oci_fetch(3), oci_fetch_all(3), oci_fetch_assoc(3), oci_fetch_array(3), oci_fetch_row(3). PHP Documentation Group OCI_FETCH_OBJECT(3)
All times are GMT -4. The time now is 12:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy