Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to remove certain words of same format from a large file

Priyanka GargPriyanka Garg MumbaiMember Posts: 1

I have a large sql file, a part of which looks like this:

ALTER TABLE `assessment_aiclassifier` MODIFY COLUMN `classifier_data` varchar(100) NOT NULL AFTER `id` , DROP INDEX `assessment_aiclassifier_714175dc` ON `assessment_aiclassifier` , DROP INDEX `assessment_aiclassifier_a36470e4` ON `assessment_aiclassifier` , DROP FOREIGN KEY `classifier_set_id_refs_id_f80cbf6` , DROP FOREIGN KEY `criterion_id_refs_id_e6ab97f2` , ADD CONSTRAINT `D3bd45d5e3c9cfdc4f3b442119adebe8` FOREIGN KEY `D3bd45d5e3c9cfdc4f3b442119adebe8` ( `classifier_set_id` ) REFERENCES `assessment_aiclassifierset` ( `id` ) ON DELETE RESTRICT ON UPDATE RESTRICT;

I want to remove few words from DROP INDEX statement for the whole file using sed in following way:

Before Modification:

DROP INDEX `assessment_aiclassifier_a36470e4` ON `assessment_aiclassifier` ,

After Modification:

DROP INDEX `assessment_aiclassifier_a36470e4` ,

I tried
sed -i 's/ON `.*` //g' filename

but it did not work. Also, tried:
sed -i 's/ON `[a-z]_[a-z]` //g' filename

Please tell how can I do it using sed?

Sign In or Register to comment.