Artificial intelligent assistant

Remove word after match Consider the following line of text (taken from a MySQL insert): "description" varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', I want to return "description" varchar(255) NOT NULL DEFAULT '', I.e. I want to remove `COLLATE utf8_unicode_ci`. However, the collation following the `COLLATE` keyword can vary depending on the original Database schema. I've come across lookaheads, but not quite sure how I could use it to remove the word.

Assuming that the field after `COLLATE` contains no whitespace, you can use a simple Awk one-liner:


awk '/COLLATE/ {$3=$4=""}1' file


This matches on the pattern `COLLATE` and then prints the entire file without the third and fourth field on the matching record (line).

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy d758fb12d8f5724cd722b2951942ec32