Re: Script for grabbing paragraphs
From: John W. Krahn (krahnj_at_acm.org)
Date: 06/08/04
- Next message: Rafley: "Ksh -- here's what I tried but failed to add integers in a file ..."
- Previous message: John W. Krahn: "Re: cat w/ file ids?"
- In reply to: Samik Raychaudhuri: "Script for grabbing paragraphs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 08 Jun 2004 21:02:24 GMT
Samik Raychaudhuri wrote:
>
> I have a scripting problem where I have a ddl and I want extract stubs
> corresponding to CREATE TABLE command.
> The ddl file looks like this:
> *************************************************************
> ------------------------------------------------
> -- DDL Statements for table "PQR"
> ------------------------------------------------
>
> CREATE TABLE "PQR" (
> "P" CHAR(6) NOT NULL ,
> "Q" CHAR(3) NOT NULL ,
> "R" CHAR(10) ,
> "S" CHAR(10) NOT NULL WITH DEFAULT USER ,
> "T" DATE NOT NULL WITH DEFAULT CURRENT DATE ,
> "U" CHAR(8) NOT NULL WITH DEFAULT '00:00:00' ) IN "TV" ;
>
> -- DDL Statements for primary key on Table "PQR"
>
> [snip]
>
> What I need is a script to grab only the CREATE TABLE commands and push
> them in some other file. These commands look like a paragraph and is
> seperated by a blank line after each command. I was trying to use awk,
> but was not sure how to go about it.
> Please help me with some pointers.
Perl has a paragraph mode that can handle it:
perl -00ne'print if /^CREATE TABLE/' original.file > new.file
John
-- use Perl; program fulfillment
- Next message: Rafley: "Ksh -- here's what I tried but failed to add integers in a file ..."
- Previous message: John W. Krahn: "Re: cat w/ file ids?"
- In reply to: Samik Raychaudhuri: "Script for grabbing paragraphs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|