Hi Everyone,
I have an unusual requirement. Here is where i am stuck for sometime now...
I have this text file.. lets say .. output.sql...
it has lot of entries... here below is part of the entry...
.. . . . . . . . . . . . . . . . . .,('garbage','DirectoryTreePointOfContactRelation','tePointOfContactId','2014-05-26 10:00:29','n_leaf_pages',1,NULL,'Number of leaf pages in the index'),('garbage','DirectoryTreePointOfContactRelation','tePointOfContactId','2014-05-26 10:00:29','size',1,NULL,'Number of pages in the index'),('garbage','garbageLocation','FK_garbageLocation_parentMyId','2014-06-0410:20:19','n_diff_pfx01',3,1,'parentInstanceId'),('garbage','garbageLocation','FK_garbageLocation_parentMyId','2014-06-04 10:20:19','n_diff_pfx01',3,1,'parentInstanceId'),('garbage','garbageLocation','FK_garbageLocation_parentMyId','2014-06-04 10:20:19','n_diff_pfx 02',6,1,'parentInstanceId,id'),('garbage','garbageLocation','FK_garbageLocation_parentMyId','2014-06-04 10:20:19','n_leaf_pages',1,NULL,'Number of leaf pages in the index'), .. .. . . .. . .. . .. . . .. . ..
from some error message, i would get below details:
[root@mysqlbackup]# cat EnterpriseBackupConsoleMessages.txt | grep PRIMARY | awk -F'-' '{print $1}' | awk -F\' '{print $2}'
garbage
[root@mysqlbackup]#
[root@mysqlbackup]#cat EnterpriseBackupConsoleMessages.txt | grep PRIMARY | awk -F'-' '{print $2}'
garbageLocation
[root@mysqlbackup]#cat EnterpriseBackupConsoleMessages.txt | grep PRIMARY | awk -F'-' '{print $3}'
FK_garbageLocation_parentMyId
[root@mysqlbackup]#cat EnterpriseBackupConsoleMessages.txt | grep PRIMARY | awk -F'-' '{print $4}' | awk -F\' '{print $1}'
n_diff_pfx01
[root@mysqlbackup]#
So i will store these fields in variables as below:
firstWord=garbage
secondWord=garbageLocation
thirdWord=FK_garbageLocation_parentMyId
fourthWord=n_diff_pfx01
these variable has the same contents as highlighted in red in the text file.Now what i want to achieve is, delete the first occurrence of this matching pattern.
That is delete the first occurence pattern starting from '(' till '),'
i mean to delete the entry
('garbage','garbageLocation','FK_garbageLocation_parentMyId','2014-06-0410:20:19','n_diff_pfx01',3,1,'parentInstanceId'),
I need a sed -i command so that it removes this first occurence, and efficiently fast (the max file size is 5MB) such that final output will be as below,
.. . . . . . . . . . . . . . . . . .,('garbage','DirectoryTreePointOfContactRelation','tePointOfContactId','2014-05-26 10:00:29','n_leaf_pages',1,NULL,'Number of leaf pages in the index'),('garbage','DirectoryTreePointOfContactRelation','tePointOfContactId','2014-05-26 10:00:29','size',1,NULL,'Number of pages in the index'),('garbage','garbageLocation','FK_garbageLocation_parentMyId','2014-06-04 10:20:19','n_diff_pfx01',3,1,'parentInstanceId'),('garbage','garbageLocation','FK_garbageLocation_parentMyId','2014-06-04 10:20:19','n_diff_pfx 02',6,1,'parentInstanceId,id'),('garbage','garbageLocation','FK_garbageLocation_parentMyId','2014-06-04 10:20:19','n_leaf_pages',1,NULL,'Number of leaf pages in the index'), .. .. . . .. . .. . .. . . .. . ..
any help or guidance on how to achieve this is deeply appreciated.