Re: Script for grabbing paragraphs

From: John W. Krahn (krahnj_at_acm.org)
Date: 06/08/04


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


Relevant Pages

  • Script for grabbing paragraphs
    ... I have a scripting problem where I have a ddl and I want extract stubs ... The ddl file looks like this: ... seperated by a blank line after each command. ...
    (comp.unix.shell)
  • Re: Script for grabbing paragraphs
    ... > I have a scripting problem where I have a ddl and I want extract stubs ... > The ddl file looks like this: ... > seperated by a blank line after each command. ... If so then the following awk will work (assumes that the original is a file ...
    (comp.unix.shell)
  • Re: Wait for background processes to complete
    ... To be able to execute commands in the background and wait for their ... The documentation I am referring to is http://perldoc.perl.org/. ... You can run a command in the background with: ... There is a general problem with perl documentation: ...
    (comp.lang.perl.misc)
  • Re: Perl For Amateur Computer Programmers
    ... >professional computer programmers could use with the same ease as Basic. ... >Perl For Amateur Computer Programmers ... Also, taking into account that you're appealing to "scientists", it ... Also, as a side note, you seem to use the noun "command" in a naive ...
    (comp.lang.perl.misc)
  • Obtaining complete Unix command line that evoked script as string
    ... If there is a more appropriate list for this, let me know; the other perl lists I've seen seem to specialised for this. ... Note this is not just the arguments of the call to the script, but everything including pipes and redirects, etc., e.g. ... Ideally the perl interpreter would grab the complete command line as its evoked and I'd access this via a variable. ...
    (perl.beginners)