Skip to content

Instantly share code, notes, and snippets.

@michaelsanford
Last active August 29, 2015 14:18
Show Gist options
  • Save michaelsanford/4b8ea457a9c2b43d2204 to your computer and use it in GitHub Desktop.
Save michaelsanford/4b8ea457a9c2b43d2204 to your computer and use it in GitHub Desktop.
Nuke mysql conditional comment markers in vim
Two vim editor commands to nuke mysql conditional comment markers in
MySQL dumps, but not the statement within them:
: %s/\/\*!\d\+\s//g
: %s/\*\///g
Or you can use sed:
sed -i 's/\/\*!\d\+\s//g' dump.sql
sed -i 's/\*\///g' dump.sql
@michaelsanford
Copy link
Author

This will turn

/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;

into

SET @saved_cs_client     = @@character_set_client ;
SET character_set_client = utf8 ;

(Conditional comments invariably break my database dumps, even with the same mysql version.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment