Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Drupal 8 - use sed to strip uuid line from exported config files

[Drupal 8] use sed (on OSX) to strip the uuid line from exported config files being used for module default configuration; i.e. [module_name]/config/optional|install

NOTE: this can also by bypassed in the export by using Drupal Cnnsole and including the --remove-uuid flag. Also using the --remove-config-hash flag can help prevent additional headaches.

Ex: drupal config:export --directory=”[full-path-to-location]” --tar --remove-uuid --remove-config-hash

The UUID should never be included when using when using these exported config yaml files as the default configuration pagaged with a custom module. This is suppoedly not to be a thing in the exported yaml files at some point, but until then stripping the uuid line out is a manual process which can be a pain as there can be a lot of files.

To automate this, run the following sed command in the directory containing the yaml files:

sed -i.bak '/^uuid: /d' ./*

The i.bak arg will create a backup of the affected file. When satistifed with the results, you can safely get rid of the .bak files:

rm *.bak


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