I have a yaml config, and I want to replace one of the fields with a new value?
Here is an example of the yaml config:
application: "app_name"
pipeline: "app-pipeline"
parameters:
spinnaker_environment: "production"
perform_cleanup: false
build_image_tag: "foobar"
I want to replace "foobar" under the build_image_tag field and replace it with a different value like "latest". How do I do this?
I tried the following:
sed '/^parameters:/{n;s/build_image_tag:.*/build_image_tag: "latest"/;}' exec.yml
But that didn't seem to work. The yaml config should look like this:
application: "app_name"
pipeline: "app-pipeline"
parameters:
spinnaker_environment: "production"
perform_cleanup: false
build_image_tag: "latest"
With
go yqorpython yq, the proper tools:yquse the same syntax thanjqforJSON-iis the same assed -i: replace on the fly