cat > tble
blah blah
blah sdfsdf dsdf sdf .d.f ..df .. sdf..
create table NextID (
id int auto_increment,
zoneID int,
entityName varchar(64),
nextID int,
lastModified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
primary key(id)
) engine=Innodb;
sdfsdf.
.
.
CREATE TABLE ReplicatorInfo (
id INT(11) NOT NULL AUTO_INCREMENT,
lastMessageReceivedTime TIMESTAMP DEFAULT 0,
lastModified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY ( id )
)ENGINE=INNODB;
blah blha etc etc
.
.
.
[root@dunkin-ds-dev-103 vivek]# perl -e 'print reverse <>' "tble"|perl -lne '(/\s+engine=Innodb/i .. /create\s+table/i) && print;'|perl -e 'print reverse <>' > onlytables.sql
[root@vivek]#
[root@vivek]#
[root@vivek]# cat onlytables.sql
create table NextID (
id int auto_increment,
zoneID int,
entityName varchar(64),
nextID int,
lastModified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
primary key(id)
) engine=Innodb;
[root@vivek]#
consider the above scenario, the expected output after executing the above perl statement
should be
cat onlytables.sql
create table NextID (
id int auto_increment,
zoneID int,
entityName varchar(64),
nextID int,
lastModified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
primary key(id)
) engine=Innodb;
CREATE TABLE ReplicatorInfo (
id INT(11) NOT NULL AUTO_INCREMENT,
lastMessageReceivedTime TIMESTAMP DEFAULT 0,
lastModified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY ( id )
)ENGINE=INNODB;
(i dont need new awk statements)i just want to modify the perl statement used above cause the print reverse function is required for other scenarions.. i just want to make it case insensitive for "create table" and "engine=innodb" which apparently is not working as i desplayed the output at the start..
perl -e 'print reverse <>' "tble"|perl -lne '(/\s+engine=Innodb/i .. /create\s+table/i) && print;'|perl -e 'print reverse <>' > onlytables.sql