From 25c9c22d8d80ebe77a452feb1556c4389910ac9d Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 20 Jun 2018 13:42:00 +1000 Subject: [PATCH] Updating docs --- README.md | 11 ++--- docs/convert/index.html | 2 +- docs/create/index.html | 2 +- docs/delete/index.html | 75 ++++++++++++++++++++++++++++++++- docs/index.html | 2 +- docs/merge/index.html | 79 ++++++++++++++++++++++++++++++++++- docs/read/index.html | 27 ++++++++++++ docs/search/search_index.json | 53 +++++++++++++++++++---- docs/sitemap.xml | 14 +++---- docs/write/index.html | 72 ++++++++++++++++++++++++++++++- examples/data3.yaml | 6 +-- mkdocs/convert.md | 2 +- mkdocs/create.md | 2 +- mkdocs/delete.md | 51 +++++++++++++++++++++- mkdocs/index.md | 2 +- mkdocs/merge.md | 57 ++++++++++++++++++++++++- mkdocs/read.md | 14 +++++++ mkdocs/write.md | 47 ++++++++++++++++++++- 18 files changed, 474 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 16f28463..341630d1 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ sudo apt install yq -y ``` or, [Download latest binary](https://github.com/mikefarah/yq/releases/latest) or alternatively: ``` -go get gopkg.in/mikefarah/yq.v1 +go get gopkg.in/mikefarah/yq.v2 ``` ## Run with Docker @@ -50,6 +50,7 @@ docker run -it -v ${PWD}:/workdir mikefarah/yq sh - Pipe data in by using '-' - Merge multiple yaml files where each additional file sets values for missing or null value keys. - Merge multiple yaml files with overwrite to support overriding previous values. +- Supports multiple documents in a single yaml file ## [Usage](http://mikefarah.github.io/yq/) @@ -61,12 +62,12 @@ Usage: yq [command] Available Commands: - delete yq d [--inplace/-i] sample.yaml a.b.c + delete yq d [--inplace/-i] [--doc/-d document_index] sample.yaml a.b.c help Help about any command - merge yq m [--inplace/-i] [--overwrite/-x] sample.yaml sample2.yaml + merge yq m [--inplace/-i] [--doc/-d document_index] [--overwrite/-x] sample.yaml sample2.yaml new yq n [--script/-s script_file] a.b.c newValueForC - read yq r sample.yaml a.b.c - write yq w [--inplace/-i] [--script/-s script_file] sample.yaml a.b.c newValueForC + read yq r [--doc/-d document_index] sample.yaml a.b.c + write yq w [--inplace/-i] [--script/-s script_file] [--doc/-d document_index] sample.yaml a.b.c newValueForC Flags: -h, --help help for yq diff --git a/docs/convert/index.html b/docs/convert/index.html index dfcc0bf1..acbb11ae 100644 --- a/docs/convert/index.html +++ b/docs/convert/index.html @@ -372,7 +372,7 @@

Convert

Yaml to Json

-

To convert output to json, use the --tojson (or -j) flag. This can be used with any command.

+

To convert output to json, use the --tojson (or -j) flag. This can only be used with the read command.

Given a sample.yaml file of:

b:
   c: 2
diff --git a/docs/create/index.html b/docs/create/index.html
index abf3e303..9f7a45f2 100644
--- a/docs/create/index.html
+++ b/docs/create/index.html
@@ -385,7 +385,7 @@
                 
                   

Create

-

Yaml files can be created using the 'new' command. This works in the same way as the write command, but you don't pass in an existing Yaml file.

+

Yaml files can be created using the 'new' command. This works in the same way as the write command, but you don't pass in an existing Yaml file. Currently this does not support creating multiple documents in a single yaml file.

yq n <path> <new value>
 
diff --git a/docs/delete/index.html b/docs/delete/index.html index 892497b9..2e112c65 100644 --- a/docs/delete/index.html +++ b/docs/delete/index.html @@ -287,6 +287,20 @@ Deleting nodes in-place + + +
  • + + Multiple Documents - delete from single document + + +
  • + +
  • + + Multiple Documents - delete from all documents + +
  • @@ -385,6 +399,20 @@ Deleting nodes in-place +
  • + +
  • + + Multiple Documents - delete from single document + + +
  • + +
  • + + Multiple Documents - delete from all documents + +
  • @@ -413,10 +441,9 @@

    Delete

    -
    yq d <yaml_file|json_file> <path_to_delete>
    +                
    yq d <yaml_file> <path_to_delete>
     
    -

    This command can take a json file as input too, and will output yaml unless specified to export as json (-j)

    To Stdout

    Given a sample.yaml file of:

    b:
    @@ -469,6 +496,50 @@
     

    will update the sample.yaml file so that the 'c' node is deleted

    +

    Multiple Documents - delete from single document

    +

    Given a sample.yaml file of:

    +
    something: else
    +field: leaveMe
    +---
    +b:
    +  c: 2
    +field: deleteMe
    +
    + +

    then

    +
    yq w -d1 sample.yaml field
    +
    + +

    will output:

    +
    something: else
    +field: leaveMe
    +---
    +b:
    +  c: 2
    +
    + +

    Multiple Documents - delete from all documents

    +

    Given a sample.yaml file of:

    +
    something: else
    +field: deleteMe
    +---
    +b:
    +  c: 2
    +field: deleteMeToo
    +
    + +

    then

    +
    yq w -d'*' sample.yaml field
    +
    + +

    will output:

    +
    something: else
    +---
    +b:
    +  c: 2
    +
    + +

    Note that '*' is in quotes to avoid being interpreted by your shell.

    Keys with dots

    When specifying a key that has a dot use key lookup indicator.

    b:
    diff --git a/docs/index.html b/docs/index.html
    index 5cc267f8..aa50f6db 100644
    --- a/docs/index.html
    +++ b/docs/index.html
    @@ -380,7 +380,7 @@ sudo apt install yq -y
     

    or, Download latest binary or alternatively:

    -
    go get gopkg.in/mikefarah/yq.v1
    +
    go get gopkg.in/mikefarah/yq.v2
     

    View on GitHub

    diff --git a/docs/merge/index.html b/docs/merge/index.html index c8007d9d..41e10c80 100644 --- a/docs/merge/index.html +++ b/docs/merge/index.html @@ -325,6 +325,20 @@
  • +
  • + + Multiple Documents - merge into single document + + +
  • + +
  • + + Multiple Documents - merge into all documents + + +
  • + @@ -380,6 +394,20 @@ +
  • + + Multiple Documents - merge into single document + + +
  • + +
  • + + Multiple Documents - merge into all documents + + +
  • + @@ -401,10 +429,9 @@

    Yaml files can be merged using the 'merge' command. Each additional file merged with the first file will set values for any key not existing already or where the key has no value.

    -
    yq m <yaml_file|json_file> <path>...
    +
    yq m <yaml_file> <path>...
     
    -

    This command can take a json file as input too, and will output yaml unless specified to export as json (-j)

    To Stdout

    Given a data1.yaml file of:

    a: simple
    @@ -497,6 +524,54 @@ d: false
     
     

    Notice that 'b' does not result in the merging of the values within an array. The underlying library does not currently handle merging values within an array.

    +

    Multiple Documents - merge into single document

    +

    Currently yq only has multi-document support for the first document being merged into. The remaining yaml files will have their first document selected.

    +

    Given a data1.yaml file of:

    +
    something: else
    +---
    +a: simple
    +b: cat
    +
    + +

    and data3.yaml file of:

    +
    b: dog
    +
    + +

    then

    +
    yq m -x -d1 data1.yaml data3.yaml
    +
    + +

    will output:

    +
    something: else
    +---
    +a: simple
    +b: dog
    +
    + +

    Multiple Documents - merge into all documents

    +

    Currently yq only has multi-document support for the first document being merged into. The remaining yaml files will have their first document selected.

    +

    Given a data1.yaml file of:

    +
    something: else
    +---
    +a: simple
    +b: cat
    +
    + +

    and data3.yaml file of:

    +
    b: dog
    +
    + +

    then

    +
    yq m -x -d'*' data1.yaml data3.yaml
    +
    + +

    will output:

    +
    b: dog
    +something: else
    +---
    +a: simple
    +b: dog
    +
    diff --git a/docs/read/index.html b/docs/read/index.html index 07097b27..8e8d2d0f 100644 --- a/docs/read/index.html +++ b/docs/read/index.html @@ -256,6 +256,13 @@ Splat + + +
  • + + Multiple Documents + +
  • @@ -385,6 +392,13 @@ Splat +
  • + +
  • + + Multiple Documents + +
  • @@ -467,6 +481,19 @@ bob: - apples
  • +

    Multiple Documents

    +

    Given a sample.yaml file of:

    +
    something: else
    +---
    +b:
    +  c: 2
    +
    + +

    then

    +
    yq r -d1 sample.yaml b.c
    +
    + +

    will output the value of '2'.

    Arrays

    You can give an index to access a specific element: e.g.: given a sample file of

    diff --git a/docs/search/search_index.json b/docs/search/search_index.json index 45dce4c5..04845b5f 100644 --- a/docs/search/search_index.json +++ b/docs/search/search_index.json @@ -2,7 +2,7 @@ "docs": [ { "location": "/", - "text": "yq\n\u00b6\n\n\nyq is a lightweight and portable command-line YAML processor\n\n\nThe aim of the project is to be the \njq\n or sed of yaml files.\n\n\nInstall\n\u00b6\n\n\nOn MacOS:\n\n\nbrew install yq\n\n\n\n\nOn Ubuntu and other Linux distros supporting \nsnap\n packages:\n\n\nsnap install yq\n\n\n\n\nOn Ubuntu 16.04 or higher from Debian package:\n\n\nsudo add-apt-repository ppa:rmescandon/yq\nsudo apt update\nsudo apt install yq -y\n\n\n\n\nor, \nDownload latest binary\n or alternatively:\n\n\ngo get gopkg.in/mikefarah/yq.v1\n\n\n\n\nView on GitHub", + "text": "yq\n\u00b6\n\n\nyq is a lightweight and portable command-line YAML processor\n\n\nThe aim of the project is to be the \njq\n or sed of yaml files.\n\n\nInstall\n\u00b6\n\n\nOn MacOS:\n\n\nbrew install yq\n\n\n\n\nOn Ubuntu and other Linux distros supporting \nsnap\n packages:\n\n\nsnap install yq\n\n\n\n\nOn Ubuntu 16.04 or higher from Debian package:\n\n\nsudo add-apt-repository ppa:rmescandon/yq\nsudo apt update\nsudo apt install yq -y\n\n\n\n\nor, \nDownload latest binary\n or alternatively:\n\n\ngo get gopkg.in/mikefarah/yq.v2\n\n\n\n\nView on GitHub", "title": "Install" }, { @@ -12,12 +12,12 @@ }, { "location": "/#install", - "text": "On MacOS: brew install yq On Ubuntu and other Linux distros supporting snap packages: snap install yq On Ubuntu 16.04 or higher from Debian package: sudo add-apt-repository ppa:rmescandon/yq\nsudo apt update\nsudo apt install yq -y or, Download latest binary or alternatively: go get gopkg.in/mikefarah/yq.v1 View on GitHub", + "text": "On MacOS: brew install yq On Ubuntu and other Linux distros supporting snap packages: snap install yq On Ubuntu 16.04 or higher from Debian package: sudo add-apt-repository ppa:rmescandon/yq\nsudo apt update\nsudo apt install yq -y or, Download latest binary or alternatively: go get gopkg.in/mikefarah/yq.v2 View on GitHub", "title": "Install" }, { "location": "/read/", - "text": "yq r \n\n\n\n\nThis command can take a json file as input too, and will output yaml unless specified to export as json (-j)\n\n\nBasic\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq r sample.yaml b.c\n\n\n\n\nwill output the value of '2'.\n\n\nFrom Stdin\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\ncat sample.yaml | yq r - b.c\n\n\n\n\nwill output the value of '2'.\n\n\nSplat\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\n---\nbob:\n item1:\n cats: bananas\n item2:\n cats: apples\n\n\n\n\nthen\n\n\nyq r sample.yaml bob.*.cats\n\n\n\n\nwill output\n\n\n- bananas\n- apples\n\n\n\n\nArrays\n\u00b6\n\n\nYou can give an index to access a specific element:\ne.g.: given a sample file of\n\n\nb:\n e:\n - name: fred\n value: 3\n - name: sam\n value: 4\n\n\n\n\nthen\n\n\nyq r sample.yaml 'b.e[1].name'\n\n\n\n\nwill output 'sam'\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.\n\n\nArray Splat\n\u00b6\n\n\ne.g.: given a sample file of\n\n\nb:\n e:\n - name: fred\n value: 3\n - name: sam\n value: 4\n\n\n\n\nthen\n\n\nyq r sample.yaml 'b.e[*].name'\n\n\n\n\nwill output:\n\n\n- fred\n- sam\n\n\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.\n\n\nKeys with dots\n\u00b6\n\n\nWhen specifying a key that has a dot use key lookup indicator.\n\n\nb:\n foo.bar: 7\n\n\n\n\nyaml r sample.yaml 'b[foo.bar]'\n\n\n\n\nyaml w sample.yaml 'b[foo.bar]' 9\n\n\n\n\nAny valid yaml key can be specified as part of a key lookup.\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.", + "text": "yq r \n\n\n\n\nThis command can take a json file as input too, and will output yaml unless specified to export as json (-j)\n\n\nBasic\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq r sample.yaml b.c\n\n\n\n\nwill output the value of '2'.\n\n\nFrom Stdin\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\ncat sample.yaml | yq r - b.c\n\n\n\n\nwill output the value of '2'.\n\n\nSplat\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\n---\nbob:\n item1:\n cats: bananas\n item2:\n cats: apples\n\n\n\n\nthen\n\n\nyq r sample.yaml bob.*.cats\n\n\n\n\nwill output\n\n\n- bananas\n- apples\n\n\n\n\nMultiple Documents\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nsomething: else\n---\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq r -d1 sample.yaml b.c\n\n\n\n\nwill output the value of '2'.\n\n\nArrays\n\u00b6\n\n\nYou can give an index to access a specific element:\ne.g.: given a sample file of\n\n\nb:\n e:\n - name: fred\n value: 3\n - name: sam\n value: 4\n\n\n\n\nthen\n\n\nyq r sample.yaml 'b.e[1].name'\n\n\n\n\nwill output 'sam'\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.\n\n\nArray Splat\n\u00b6\n\n\ne.g.: given a sample file of\n\n\nb:\n e:\n - name: fred\n value: 3\n - name: sam\n value: 4\n\n\n\n\nthen\n\n\nyq r sample.yaml 'b.e[*].name'\n\n\n\n\nwill output:\n\n\n- fred\n- sam\n\n\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.\n\n\nKeys with dots\n\u00b6\n\n\nWhen specifying a key that has a dot use key lookup indicator.\n\n\nb:\n foo.bar: 7\n\n\n\n\nyaml r sample.yaml 'b[foo.bar]'\n\n\n\n\nyaml w sample.yaml 'b[foo.bar]' 9\n\n\n\n\nAny valid yaml key can be specified as part of a key lookup.\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.", "title": "Read" }, { @@ -35,6 +35,11 @@ "text": "Given a sample.yaml file of: ---\nbob:\n item1:\n cats: bananas\n item2:\n cats: apples then yq r sample.yaml bob.*.cats will output - bananas\n- apples", "title": "Splat" }, + { + "location": "/read/#multiple-documents", + "text": "Given a sample.yaml file of: something: else\n---\nb:\n c: 2 then yq r -d1 sample.yaml b.c will output the value of '2'.", + "title": "Multiple Documents" + }, { "location": "/read/#arrays", "text": "You can give an index to access a specific element:\ne.g.: given a sample file of b:\n e:\n - name: fred\n value: 3\n - name: sam\n value: 4 then yq r sample.yaml 'b.e[1].name' will output 'sam' Note that the path is in quotes to avoid the square brackets being interpreted by your shell.", @@ -52,7 +57,7 @@ }, { "location": "/write/", - "text": "yq w \n\n\n\n\nThis command can take a json file as input too, and will output yaml unless specified to export as json (-j)\n\n\nTo Stdout\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq w sample.yaml b.c cat\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n\n\n\n\nFrom STDIN\n\u00b6\n\n\ncat sample.yaml | yq w - b.c blah\n\n\n\n\nAdding new fields\n\u00b6\n\n\nAny missing fields in the path will be created on the fly.\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq w sample.yaml b.d[0] \"new thing\"\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n d:\n - new thing\n\n\n\n\nAppending value to an array field\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n d:\n - new thing\n - foo thing\n\n\n\n\nthen\n\n\nyq w sample.yaml \"b.d[+]\" \"bar thing\"\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n d:\n - new thing\n - foo thing\n - bar thing\n\n\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.\n\n\nUpdating files in-place\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq w -i sample.yaml b.c cat\n\n\n\n\nwill update the sample.yaml file so that the value of 'c' is cat.\n\n\nUpdating multiple values with a script\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n e:\n - name: Billy Bob\n\n\n\n\nand a script update_instructions.yaml of:\n\n\nb.c: 3\nb.e[0].name: Howdy Partner\n\n\n\n\nthen\n\n\nyq w -s update_instructions.yaml sample.yaml\n\n\n\n\nwill output:\n\n\nb:\n c: 3\n e:\n - name: Howdy Partner\n\n\n\n\nAnd, of course, you can pipe the instructions in using '-':\n\n\ncat update_instructions.yaml | yq w -s - sample.yaml\n\n\n\n\nValues starting with a hyphen (or dash)\n\u00b6\n\n\nThe flag terminator needs to be used to stop the app from attempting to parse the subsequent arguments as flags:\n\n\nyq w -- my.path -3\n\n\n\n\nwill output\n\n\nmy:\n path: -3\n\n\n\n\nKeys with dots\n\u00b6\n\n\nWhen specifying a key that has a dot use key lookup indicator.\n\n\nb:\n foo.bar: 7\n\n\n\n\nyaml r sample.yaml 'b[foo.bar]'\n\n\n\n\nyaml w sample.yaml 'b[foo.bar]' 9\n\n\n\n\nAny valid yaml key can be specified as part of a key lookup.\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.", + "text": "yq w \n\n\n\n\nTo Stdout\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq w sample.yaml b.c cat\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n\n\n\n\nFrom STDIN\n\u00b6\n\n\ncat sample.yaml | yq w - b.c blah\n\n\n\n\nAdding new fields\n\u00b6\n\n\nAny missing fields in the path will be created on the fly.\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq w sample.yaml b.d[0] \"new thing\"\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n d:\n - new thing\n\n\n\n\nAppending value to an array field\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n d:\n - new thing\n - foo thing\n\n\n\n\nthen\n\n\nyq w sample.yaml \"b.d[+]\" \"bar thing\"\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n d:\n - new thing\n - foo thing\n - bar thing\n\n\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.\n\n\nMultiple Documents - update a single document\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nsomething: else\n---\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq w -d1 sample.yaml b.c 5\n\n\n\n\nwill output:\n\n\nsomething: else\n---\nb:\n c: 5\n\n\n\n\nMultiple Documents - update all documents\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nsomething: else\n---\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq w -d'*' sample.yaml b.c 5\n\n\n\n\nwill output:\n\n\nsomething: else\nb:\n c: 5\n---\nb:\n c: 5\n\n\n\n\nNote that '*' is in quotes to avoid being interpreted by your shell.\n\n\nUpdating files in-place\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq w -i sample.yaml b.c cat\n\n\n\n\nwill update the sample.yaml file so that the value of 'c' is cat.\n\n\nUpdating multiple values with a script\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n e:\n - name: Billy Bob\n\n\n\n\nand a script update_instructions.yaml of:\n\n\nb.c: 3\nb.e[0].name: Howdy Partner\n\n\n\n\nthen\n\n\nyq w -s update_instructions.yaml sample.yaml\n\n\n\n\nwill output:\n\n\nb:\n c: 3\n e:\n - name: Howdy Partner\n\n\n\n\nAnd, of course, you can pipe the instructions in using '-':\n\n\ncat update_instructions.yaml | yq w -s - sample.yaml\n\n\n\n\nValues starting with a hyphen (or dash)\n\u00b6\n\n\nThe flag terminator needs to be used to stop the app from attempting to parse the subsequent arguments as flags:\n\n\nyq w -- my.path -3\n\n\n\n\nwill output\n\n\nmy:\n path: -3\n\n\n\n\nKeys with dots\n\u00b6\n\n\nWhen specifying a key that has a dot use key lookup indicator.\n\n\nb:\n foo.bar: 7\n\n\n\n\nyaml r sample.yaml 'b[foo.bar]'\n\n\n\n\nyaml w sample.yaml 'b[foo.bar]' 9\n\n\n\n\nAny valid yaml key can be specified as part of a key lookup.\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.", "title": "Write/Update" }, { @@ -75,6 +80,16 @@ "text": "Given a sample.yaml file of: b:\n c: 2\n d:\n - new thing\n - foo thing then yq w sample.yaml \"b.d[+]\" \"bar thing\" will output: b:\n c: cat\n d:\n - new thing\n - foo thing\n - bar thing Note that the path is in quotes to avoid the square brackets being interpreted by your shell.", "title": "Appending value to an array field" }, + { + "location": "/write/#multiple-documents-update-a-single-document", + "text": "Given a sample.yaml file of: something: else\n---\nb:\n c: 2 then yq w -d1 sample.yaml b.c 5 will output: something: else\n---\nb:\n c: 5", + "title": "Multiple Documents - update a single document" + }, + { + "location": "/write/#multiple-documents-update-all-documents", + "text": "Given a sample.yaml file of: something: else\n---\nb:\n c: 2 then yq w -d'*' sample.yaml b.c 5 will output: something: else\nb:\n c: 5\n---\nb:\n c: 5 Note that '*' is in quotes to avoid being interpreted by your shell.", + "title": "Multiple Documents - update all documents" + }, { "location": "/write/#updating-files-in-place", "text": "Given a sample.yaml file of: b:\n c: 2 then yq w -i sample.yaml b.c cat will update the sample.yaml file so that the value of 'c' is cat.", @@ -97,7 +112,7 @@ }, { "location": "/delete/", - "text": "yq d \n\n\n\n\nThis command can take a json file as input too, and will output yaml unless specified to export as json (-j)\n\n\nTo Stdout\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n apples: green\n\n\n\n\nthen\n\n\nyq d sample.yaml b.c\n\n\n\n\nwill output:\n\n\nb:\n apples: green\n\n\n\n\nFrom STDIN\n\u00b6\n\n\ncat sample.yaml | yq d - b.c\n\n\n\n\nDeleting array elements\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: \n - 1\n - 2\n - 3\n\n\n\n\nthen\n\n\nyq d sample.yaml 'b.c[1]'\n\n\n\n\nwill output:\n\n\nb:\n c:\n - 1\n - 3\n\n\n\n\nDeleting nodes in-place\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n apples: green\n\n\n\n\nthen\n\n\nyq d -i sample.yaml b.c\n\n\n\n\nwill update the sample.yaml file so that the 'c' node is deleted\n\n\nKeys with dots\n\u00b6\n\n\nWhen specifying a key that has a dot use key lookup indicator.\n\n\nb:\n foo.bar: 7\n\n\n\n\nyaml r sample.yaml 'b[foo.bar]'\n\n\n\n\nyaml w sample.yaml 'b[foo.bar]' 9\n\n\n\n\nAny valid yaml key can be specified as part of a key lookup.\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.", + "text": "yq d \n\n\n\n\nTo Stdout\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n apples: green\n\n\n\n\nthen\n\n\nyq d sample.yaml b.c\n\n\n\n\nwill output:\n\n\nb:\n apples: green\n\n\n\n\nFrom STDIN\n\u00b6\n\n\ncat sample.yaml | yq d - b.c\n\n\n\n\nDeleting array elements\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: \n - 1\n - 2\n - 3\n\n\n\n\nthen\n\n\nyq d sample.yaml 'b.c[1]'\n\n\n\n\nwill output:\n\n\nb:\n c:\n - 1\n - 3\n\n\n\n\nDeleting nodes in-place\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n apples: green\n\n\n\n\nthen\n\n\nyq d -i sample.yaml b.c\n\n\n\n\nwill update the sample.yaml file so that the 'c' node is deleted\n\n\nMultiple Documents - delete from single document\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nsomething: else\nfield: leaveMe\n---\nb:\n c: 2\nfield: deleteMe\n\n\n\n\nthen\n\n\nyq w -d1 sample.yaml field\n\n\n\n\nwill output:\n\n\nsomething: else\nfield: leaveMe\n---\nb:\n c: 2\n\n\n\n\nMultiple Documents - delete from all documents\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nsomething: else\nfield: deleteMe\n---\nb:\n c: 2\nfield: deleteMeToo\n\n\n\n\nthen\n\n\nyq w -d'*' sample.yaml field\n\n\n\n\nwill output:\n\n\nsomething: else\n---\nb:\n c: 2\n\n\n\n\nNote that '*' is in quotes to avoid being interpreted by your shell.\n\n\nKeys with dots\n\u00b6\n\n\nWhen specifying a key that has a dot use key lookup indicator.\n\n\nb:\n foo.bar: 7\n\n\n\n\nyaml r sample.yaml 'b[foo.bar]'\n\n\n\n\nyaml w sample.yaml 'b[foo.bar]' 9\n\n\n\n\nAny valid yaml key can be specified as part of a key lookup.\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.", "title": "Delete" }, { @@ -120,6 +135,16 @@ "text": "Given a sample.yaml file of: b:\n c: 2\n apples: green then yq d -i sample.yaml b.c will update the sample.yaml file so that the 'c' node is deleted", "title": "Deleting nodes in-place" }, + { + "location": "/delete/#multiple-documents-delete-from-single-document", + "text": "Given a sample.yaml file of: something: else\nfield: leaveMe\n---\nb:\n c: 2\nfield: deleteMe then yq w -d1 sample.yaml field will output: something: else\nfield: leaveMe\n---\nb:\n c: 2", + "title": "Multiple Documents - delete from single document" + }, + { + "location": "/delete/#multiple-documents-delete-from-all-documents", + "text": "Given a sample.yaml file of: something: else\nfield: deleteMe\n---\nb:\n c: 2\nfield: deleteMeToo then yq w -d'*' sample.yaml field will output: something: else\n---\nb:\n c: 2 Note that '*' is in quotes to avoid being interpreted by your shell.", + "title": "Multiple Documents - delete from all documents" + }, { "location": "/delete/#keys-with-dots", "text": "When specifying a key that has a dot use key lookup indicator. b:\n foo.bar: 7 yaml r sample.yaml 'b[foo.bar]' yaml w sample.yaml 'b[foo.bar]' 9 Any valid yaml key can be specified as part of a key lookup. Note that the path is in quotes to avoid the square brackets being interpreted by your shell.", @@ -127,7 +152,7 @@ }, { "location": "/create/", - "text": "Yaml files can be created using the 'new' command. This works in the same way as the write command, but you don't pass in an existing Yaml file.\n\n\nyq n \n\n\n\n\nCreating a simple yaml file\n\u00b6\n\n\nyq n b.c cat\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n\n\n\n\nCreating using a create script\n\u00b6\n\n\nCreate scripts follow the same format as the update scripts.\n\n\nGiven a script create_instructions.yaml of:\n\n\nb.c: 3\nb.e[0].name: Howdy Partner\n\n\n\n\nthen\n\n\nyq n -s create_instructions.yaml\n\n\n\n\nwill output:\n\n\nb:\n c: 3\n e:\n - name: Howdy Partner\n\n\n\n\nYou can also pipe the instructions in:\n\n\ncat create_instructions.yaml | yq n -s -\n\n\n\n\nKeys with dots\n\u00b6\n\n\nWhen specifying a key that has a dot use key lookup indicator.\n\n\nb:\n foo.bar: 7\n\n\n\n\nyaml r sample.yaml 'b[foo.bar]'\n\n\n\n\nyaml w sample.yaml 'b[foo.bar]' 9\n\n\n\n\nAny valid yaml key can be specified as part of a key lookup.\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.", + "text": "Yaml files can be created using the 'new' command. This works in the same way as the write command, but you don't pass in an existing Yaml file. Currently this does not support creating multiple documents in a single yaml file.\n\n\nyq n \n\n\n\n\nCreating a simple yaml file\n\u00b6\n\n\nyq n b.c cat\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n\n\n\n\nCreating using a create script\n\u00b6\n\n\nCreate scripts follow the same format as the update scripts.\n\n\nGiven a script create_instructions.yaml of:\n\n\nb.c: 3\nb.e[0].name: Howdy Partner\n\n\n\n\nthen\n\n\nyq n -s create_instructions.yaml\n\n\n\n\nwill output:\n\n\nb:\n c: 3\n e:\n - name: Howdy Partner\n\n\n\n\nYou can also pipe the instructions in:\n\n\ncat create_instructions.yaml | yq n -s -\n\n\n\n\nKeys with dots\n\u00b6\n\n\nWhen specifying a key that has a dot use key lookup indicator.\n\n\nb:\n foo.bar: 7\n\n\n\n\nyaml r sample.yaml 'b[foo.bar]'\n\n\n\n\nyaml w sample.yaml 'b[foo.bar]' 9\n\n\n\n\nAny valid yaml key can be specified as part of a key lookup.\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.", "title": "Create" }, { @@ -147,12 +172,12 @@ }, { "location": "/convert/", - "text": "Yaml to Json\n\u00b6\n\n\nTo convert output to json, use the --tojson (or -j) flag. This can be used with any command.\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq r -j sample.yaml b.c\n\n\n\n\nwill output\n\n\n{\"b\":{\"c\":2}}\n\n\n\n\nJson to Yaml\n\u00b6\n\n\nTo read in json, just pass in a json file instead of yaml, it will just work :)\n\n\ne.g given a json file\n\n\n{\"a\":\"Easy! as one two three\",\"b\":{\"c\":2,\"d\":[3,4]}}\n\n\n\n\nthen\n\n\nyq r sample.json\n\n\n\n\nwill output\n\n\na: Easy! as one two three\nb:\n c: 2\n d:\n - 3\n - 4", + "text": "Yaml to Json\n\u00b6\n\n\nTo convert output to json, use the --tojson (or -j) flag. This can only be used with the read command.\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq r -j sample.yaml b.c\n\n\n\n\nwill output\n\n\n{\"b\":{\"c\":2}}\n\n\n\n\nJson to Yaml\n\u00b6\n\n\nTo read in json, just pass in a json file instead of yaml, it will just work :)\n\n\ne.g given a json file\n\n\n{\"a\":\"Easy! as one two three\",\"b\":{\"c\":2,\"d\":[3,4]}}\n\n\n\n\nthen\n\n\nyq r sample.json\n\n\n\n\nwill output\n\n\na: Easy! as one two three\nb:\n c: 2\n d:\n - 3\n - 4", "title": "Convert" }, { "location": "/convert/#yaml-to-json", - "text": "To convert output to json, use the --tojson (or -j) flag. This can be used with any command. Given a sample.yaml file of: b:\n c: 2 then yq r -j sample.yaml b.c will output {\"b\":{\"c\":2}}", + "text": "To convert output to json, use the --tojson (or -j) flag. This can only be used with the read command. Given a sample.yaml file of: b:\n c: 2 then yq r -j sample.yaml b.c will output {\"b\":{\"c\":2}}", "title": "Yaml to Json" }, { @@ -162,7 +187,7 @@ }, { "location": "/merge/", - "text": "Yaml files can be merged using the 'merge' command. Each additional file merged with the first file will\nset values for any key not existing already or where the key has no value.\n\n\nyq m ...\n\n\n\n\nThis command can take a json file as input too, and will output yaml unless specified to export as json (-j)\n\n\nTo Stdout\n\u00b6\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data2.yaml file of:\n\n\na: other\nc:\n test: 1\n\n\n\n\nthen\n\n\nyq m data1.yaml data2.yaml\n\n\n\n\nwill output:\n\n\na: simple\nb: [1, 2]\nc:\n test: 1\n\n\n\n\nUpdating files in-place\n\u00b6\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data2.yaml file of:\n\n\na: other\nc:\n test: 1\n\n\n\n\nthen\n\n\nyq m -i data1.yaml data2.yaml\n\n\n\n\nwill update the data1.yaml file so that the value of 'c' is 'test: 1'.\n\n\nOverwrite values\n\u00b6\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data2.yaml file of:\n\n\na: other\nc:\n test: 1\n\n\n\n\nthen\n\n\nyq m -x data1.yaml data2.yaml\n\n\n\n\nwill output:\n\n\na: other\nb: [1, 2]\nc:\n test: 1\n\n\n\n\nOverwrite values with arrays\n\u00b6\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data3.yaml file of:\n\n\nb: [2, 3, 4]\nc:\n test: 2\n other: true\nd: false\n\n\n\n\nthen\n\n\nyq m -x data1.yaml data3.yaml\n\n\n\n\nwill output:\n\n\na: simple\nb: [2, 3, 4]\nc:\n test: 2\n other: true\nd: false\n\n\n\n\nNotice that 'b' does not result in the merging of the values within an array. The underlying library does not\ncurrently handle merging values within an array.", + "text": "Yaml files can be merged using the 'merge' command. Each additional file merged with the first file will\nset values for any key not existing already or where the key has no value.\n\n\nyq m ...\n\n\n\n\nTo Stdout\n\u00b6\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data2.yaml file of:\n\n\na: other\nc:\n test: 1\n\n\n\n\nthen\n\n\nyq m data1.yaml data2.yaml\n\n\n\n\nwill output:\n\n\na: simple\nb: [1, 2]\nc:\n test: 1\n\n\n\n\nUpdating files in-place\n\u00b6\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data2.yaml file of:\n\n\na: other\nc:\n test: 1\n\n\n\n\nthen\n\n\nyq m -i data1.yaml data2.yaml\n\n\n\n\nwill update the data1.yaml file so that the value of 'c' is 'test: 1'.\n\n\nOverwrite values\n\u00b6\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data2.yaml file of:\n\n\na: other\nc:\n test: 1\n\n\n\n\nthen\n\n\nyq m -x data1.yaml data2.yaml\n\n\n\n\nwill output:\n\n\na: other\nb: [1, 2]\nc:\n test: 1\n\n\n\n\nOverwrite values with arrays\n\u00b6\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data3.yaml file of:\n\n\nb: [2, 3, 4]\nc:\n test: 2\n other: true\nd: false\n\n\n\n\nthen\n\n\nyq m -x data1.yaml data3.yaml\n\n\n\n\nwill output:\n\n\na: simple\nb: [2, 3, 4]\nc:\n test: 2\n other: true\nd: false\n\n\n\n\nNotice that 'b' does not result in the merging of the values within an array. The underlying library does not\ncurrently handle merging values within an array.\n\n\nMultiple Documents - merge into single document\n\u00b6\n\n\nCurrently yq only has multi-document support for the \nfirst\n document being merged into. The remaining yaml files will have their first document selected.\n\n\nGiven a data1.yaml file of:\n\n\nsomething: else\n---\na: simple\nb: cat\n\n\n\n\nand data3.yaml file of:\n\n\nb: dog\n\n\n\n\nthen\n\n\nyq m -x -d1 data1.yaml data3.yaml\n\n\n\n\nwill output:\n\n\nsomething: else\n---\na: simple\nb: dog\n\n\n\n\nMultiple Documents - merge into all documents\n\u00b6\n\n\nCurrently yq only has multi-document support for the \nfirst\n document being merged into. The remaining yaml files will have their first document selected.\n\n\nGiven a data1.yaml file of:\n\n\nsomething: else\n---\na: simple\nb: cat\n\n\n\n\nand data3.yaml file of:\n\n\nb: dog\n\n\n\n\nthen\n\n\nyq m -x -d'*' data1.yaml data3.yaml\n\n\n\n\nwill output:\n\n\nb: dog\nsomething: else\n---\na: simple\nb: dog", "title": "Merge" }, { @@ -184,6 +209,16 @@ "location": "/merge/#overwrite-values-with-arrays", "text": "Given a data1.yaml file of: a: simple\nb: [1, 2] and data3.yaml file of: b: [2, 3, 4]\nc:\n test: 2\n other: true\nd: false then yq m -x data1.yaml data3.yaml will output: a: simple\nb: [2, 3, 4]\nc:\n test: 2\n other: true\nd: false Notice that 'b' does not result in the merging of the values within an array. The underlying library does not\ncurrently handle merging values within an array.", "title": "Overwrite values with arrays" + }, + { + "location": "/merge/#multiple-documents-merge-into-single-document", + "text": "Currently yq only has multi-document support for the first document being merged into. The remaining yaml files will have their first document selected. Given a data1.yaml file of: something: else\n---\na: simple\nb: cat and data3.yaml file of: b: dog then yq m -x -d1 data1.yaml data3.yaml will output: something: else\n---\na: simple\nb: dog", + "title": "Multiple Documents - merge into single document" + }, + { + "location": "/merge/#multiple-documents-merge-into-all-documents", + "text": "Currently yq only has multi-document support for the first document being merged into. The remaining yaml files will have their first document selected. Given a data1.yaml file of: something: else\n---\na: simple\nb: cat and data3.yaml file of: b: dog then yq m -x -d'*' data1.yaml data3.yaml will output: b: dog\nsomething: else\n---\na: simple\nb: dog", + "title": "Multiple Documents - merge into all documents" } ] } \ No newline at end of file diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 386f769f..3b282c17 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -4,7 +4,7 @@ / - 2018-06-18 + 2018-06-20 daily @@ -12,7 +12,7 @@ /read/ - 2018-06-18 + 2018-06-20 daily @@ -20,7 +20,7 @@ /write/ - 2018-06-18 + 2018-06-20 daily @@ -28,7 +28,7 @@ /delete/ - 2018-06-18 + 2018-06-20 daily @@ -36,7 +36,7 @@ /create/ - 2018-06-18 + 2018-06-20 daily @@ -44,7 +44,7 @@ /convert/ - 2018-06-18 + 2018-06-20 daily @@ -52,7 +52,7 @@ /merge/ - 2018-06-18 + 2018-06-20 daily diff --git a/docs/write/index.html b/docs/write/index.html index dbf82f09..bc0422f8 100644 --- a/docs/write/index.html +++ b/docs/write/index.html @@ -275,6 +275,20 @@ Appending value to an array field + + +
  • + + Multiple Documents - update a single document + + +
  • + +
  • + + Multiple Documents - update all documents + +
  • @@ -406,6 +420,20 @@ Appending value to an array field +
  • + +
  • + + Multiple Documents - update a single document + + +
  • + +
  • + + Multiple Documents - update all documents + +
  • @@ -455,10 +483,9 @@

    Write/Update

    -
    yq w <yaml_file|json_file> <path> <new value>
    +                
    yq w <yaml_file> <path> <new value>
     
    -

    This command can take a json file as input too, and will output yaml unless specified to export as json (-j)

    To Stdout

    Given a sample.yaml file of:

    b:
    @@ -519,6 +546,47 @@
     

    Note that the path is in quotes to avoid the square brackets being interpreted by your shell.

    +

    Multiple Documents - update a single document

    +

    Given a sample.yaml file of:

    +
    something: else
    +---
    +b:
    +  c: 2
    +
    + +

    then

    +
    yq w -d1 sample.yaml b.c 5
    +
    + +

    will output:

    +
    something: else
    +---
    +b:
    +  c: 5
    +
    + +

    Multiple Documents - update all documents

    +

    Given a sample.yaml file of:

    +
    something: else
    +---
    +b:
    +  c: 2
    +
    + +

    then

    +
    yq w -d'*' sample.yaml b.c 5
    +
    + +

    will output:

    +
    something: else
    +b:
    +  c: 5
    +---
    +b:
    +  c: 5
    +
    + +

    Note that '*' is in quotes to avoid being interpreted by your shell.

    Updating files in-place

    Given a sample.yaml file of:

    b:
    diff --git a/examples/data3.yaml b/examples/data3.yaml
    index 655191ab..fbe63d8c 100644
    --- a/examples/data3.yaml
    +++ b/examples/data3.yaml
    @@ -1,5 +1 @@
    -b: [2, 3, 4]
    -c:
    -  test: 2
    -  other: true
    -d: false
    +b: dog
    \ No newline at end of file
    diff --git a/mkdocs/convert.md b/mkdocs/convert.md
    index c5b6821c..369bc576 100644
    --- a/mkdocs/convert.md
    +++ b/mkdocs/convert.md
    @@ -1,5 +1,5 @@
     ### Yaml to Json
    -To convert output to json, use the --tojson (or -j) flag. This can be used with any command.
    +To convert output to json, use the --tojson (or -j) flag. This can only be used with the read command.
     
     Given a sample.yaml file of:
     ```yaml
    diff --git a/mkdocs/create.md b/mkdocs/create.md
    index 374b2401..7617fd85 100644
    --- a/mkdocs/create.md
    +++ b/mkdocs/create.md
    @@ -1,4 +1,4 @@
    -Yaml files can be created using the 'new' command. This works in the same way as the write command, but you don't pass in an existing Yaml file.
    +Yaml files can be created using the 'new' command. This works in the same way as the write command, but you don't pass in an existing Yaml file. Currently this does not support creating multiple documents in a single yaml file.
     
     ```
     yq n  
    diff --git a/mkdocs/delete.md b/mkdocs/delete.md
    index c5dd9989..4a521e8e 100644
    --- a/mkdocs/delete.md
    +++ b/mkdocs/delete.md
    @@ -1,7 +1,6 @@
     ```
    -yq d  
    +yq d  
     ```
    -{!snippets/works_with_json.md!}
     
     ### To Stdout
     Given a sample.yaml file of:
    @@ -60,4 +59,52 @@ yq d -i sample.yaml b.c
     will update the sample.yaml file so that the 'c' node is deleted
     
     
    +
    +### Multiple Documents - delete from single document
    +Given a sample.yaml file of:
    +```yaml
    +something: else
    +field: leaveMe
    +---
    +b:
    +  c: 2
    +field: deleteMe
    +```
    +then
    +```bash
    +yq w -d1 sample.yaml field
    +```
    +will output:
    +```yaml
    +something: else
    +field: leaveMe
    +---
    +b:
    +  c: 2
    +```
    +
    +### Multiple Documents - delete from all documents
    +Given a sample.yaml file of:
    +```yaml
    +something: else
    +field: deleteMe
    +---
    +b:
    +  c: 2
    +field: deleteMeToo
    +```
    +then
    +```bash
    +yq w -d'*' sample.yaml field
    +```
    +will output:
    +```yaml
    +something: else
    +---
    +b:
    +  c: 2
    +```
    +
    +Note that '*' is in quotes to avoid being interpreted by your shell.
    +
     {!snippets/keys_with_dots.md!}
    diff --git a/mkdocs/index.md b/mkdocs/index.md
    index 0858b6bb..455058ea 100644
    --- a/mkdocs/index.md
    +++ b/mkdocs/index.md
    @@ -20,7 +20,7 @@ sudo apt install yq -y
     ```
     or, [Download latest binary](https://github.com/mikefarah/yq/releases/latest) or alternatively:
     ```
    -go get gopkg.in/mikefarah/yq.v1
    +go get gopkg.in/mikefarah/yq.v2
     ```
     
     [View on GitHub](https://github.com/mikefarah/yq)
    diff --git a/mkdocs/merge.md b/mkdocs/merge.md
    index 0c622d80..b2c0c5a1 100644
    --- a/mkdocs/merge.md
    +++ b/mkdocs/merge.md
    @@ -2,9 +2,9 @@ Yaml files can be merged using the 'merge' command. Each additional file merged
     set values for any key not existing already or where the key has no value.
     
     ```
    -yq m  ...
    +yq m  ...
     ```
    -{!snippets/works_with_json.md!}
    +
     
     ### To Stdout
     Given a data1.yaml file of:
    @@ -102,3 +102,56 @@ d: false
     
     Notice that 'b' does not result in the merging of the values within an array. The underlying library does not
     currently handle merging values within an array.
    +
    +### Multiple Documents - merge into single document
    +Currently yq only has multi-document support for the _first_ document being merged into. The remaining yaml files will have their first document selected.
    +
    +Given a data1.yaml file of:
    +```yaml
    +something: else
    +---
    +a: simple
    +b: cat
    +```
    +and data3.yaml file of:
    +```yaml
    +b: dog
    +```
    +then
    +```bash
    +yq m -x -d1 data1.yaml data3.yaml
    +```
    +will output:
    +```yaml
    +something: else
    +---
    +a: simple
    +b: dog
    +```
    +
    +### Multiple Documents - merge into all documents
    +Currently yq only has multi-document support for the _first_ document being merged into. The remaining yaml files will have their first document selected.
    +
    +Given a data1.yaml file of:
    +```yaml
    +something: else
    +---
    +a: simple
    +b: cat
    +```
    +and data3.yaml file of:
    +```yaml
    +b: dog
    +```
    +then
    +```bash
    +yq m -x -d'*' data1.yaml data3.yaml
    +```
    +will output:
    +```yaml
    +b: dog
    +something: else
    +---
    +a: simple
    +b: dog
    +```
    \ No newline at end of file
    diff --git a/mkdocs/read.md b/mkdocs/read.md
    index e7c339a1..8efde9d7 100644
    --- a/mkdocs/read.md
    +++ b/mkdocs/read.md
    @@ -43,6 +43,20 @@ will output
     - apples
     ```
     
    +### Multiple Documents
    +Given a sample.yaml file of:
    +```yaml
    +something: else
    +---
    +b:
    +  c: 2
    +```
    +then
    +```bash
    +yq r -d1 sample.yaml b.c
    +```
    +will output the value of '2'.
    +
     ### Arrays
     You can give an index to access a specific element:
     e.g.: given a sample file of
    diff --git a/mkdocs/write.md b/mkdocs/write.md
    index 4edb1866..c41ee52a 100644
    --- a/mkdocs/write.md
    +++ b/mkdocs/write.md
    @@ -1,7 +1,6 @@
     ```
    -yq w   
    +yq w   
     ```
    -{!snippets/works_with_json.md!}
     
     ### To Stdout
     Given a sample.yaml file of:
    @@ -69,6 +68,50 @@ b:
     
     Note that the path is in quotes to avoid the square brackets being interpreted by your shell.
     
    +### Multiple Documents - update a single document
    +Given a sample.yaml file of:
    +```yaml
    +something: else
    +---
    +b:
    +  c: 2
    +```
    +then
    +```bash
    +yq w -d1 sample.yaml b.c 5
    +```
    +will output:
    +```yaml
    +something: else
    +---
    +b:
    +  c: 5
    +```
    +
    +### Multiple Documents - update all documents
    +Given a sample.yaml file of:
    +```yaml
    +something: else
    +---
    +b:
    +  c: 2
    +```
    +then
    +```bash
    +yq w -d'*' sample.yaml b.c 5
    +```
    +will output:
    +```yaml
    +something: else
    +b:
    +  c: 5
    +---
    +b:
    +  c: 5
    +```
    +
    +Note that '*' is in quotes to avoid being interpreted by your shell.
    +
     ### Updating files in-place
     Given a sample.yaml file of:
     ```yaml