Laurent Schneider suggested one liner using AWK unix command - for my last script Extract_Text.sh... see here:
awk '/^CREATE UNIQUE INDEX/{print "-- Create unique index #"++x}/^CREATE TABLE/{print "-- Create table #"++y}/^CREATE (UNIQUE INDEXTABLE)/,/;/{print}' test.sql
/^CREATE (UNIQUE INDEXTABLE)/,/;/{print}: Searches for CREATE UNIQUE INDEX or CREATE TABLE and prints the lines till the first ";" encounters.
/^CREATE UNIQUE INDEX/{print "-- Create unique index #"++x}: Searches for pattern CREATE UNIQUE INDEX and prints "-- Create unique index # and the number of it's occurance".
/^CREATE TABLE/{print "-- Create table #"++y}: Searches for pattern CREATE TABLE and prints "-- Create unique index # and the number of it's occurance".
This is indeed a better and faster than the while read loop. Below is the modified script for download:
Extract_Text_Modified.sh
NOTE: After downloading this file, please REPLACE < ; with < and > ; with >
there is no space between < and ; or > and ;
* Thanks Laurent
HEUG Alliance 2012
-
It is almost time for Alliance 2012 in Nashville. As always, we are gearing
up for a great conference. Here is my agenda -- Sessions I lead are in bold
a...
22 hours ago
0 comments:
Post a Comment