kislyuk / yq

Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents
https://kislyuk.github.io/yq/
Apache License 2.0
2.57k stars 82 forks source link

How to update/write a value in place using yq's latest version? #129

Closed dattasaurabh82 closed 3 years ago

dattasaurabh82 commented 3 years ago

Dear maintainer. I found examples in docs for Assign(Update) but it doesn't really write to the document. 😅 . Am I missing something here?

For example I have two situation:

  1. I want to append strings to an array field in an input yaml file.
    LINKS:
       -
       -
  2. And I want to update the string for a field in the same yaml file
    # from
    DIR: /home/test
    # to 
    DIR: /home/Downloads

    The update methods as illustrated:

    yq e '.LINKS[<id>] = "some string"' myfile.yaml

    shows the output dump being updated but it is not written in the file. The file has many other fields as well.

Is there a write in place methods for a file?

kislyuk commented 3 years ago

This is not the yq project you are looking for.