diff --git a/README.md b/README.md index 735d6dc..a0bb733 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ Usage: yq [command] Available Commands: + delete yq d [--inplace/-i] sample.yaml a.b.c help Help about any command merge yq m [--inplace/-i] [--overwrite/-x] sample.yaml sample2.yaml new yq n [--script/-s script_file] a.b.c newValueForC diff --git a/docs/404.html b/docs/404.html index dcf9539..d9d1d71 100644 --- a/docs/404.html +++ b/docs/404.html @@ -238,6 +238,18 @@ +
  • + + Delete + +
  • + + + + + + +
  • Create diff --git a/docs/convert/index.html b/docs/convert/index.html index 7f093a5..dfcc0bf 100644 --- a/docs/convert/index.html +++ b/docs/convert/index.html @@ -238,6 +238,18 @@ +
  • + + Delete + +
  • + + + + + + +
  • Create diff --git a/docs/create/index.html b/docs/create/index.html index e93a7fc..abf3e30 100644 --- a/docs/create/index.html +++ b/docs/create/index.html @@ -237,6 +237,18 @@ + +
  • + + Delete + +
  • + + + + + + @@ -440,7 +452,7 @@ b.e[0].name: Howdy Partner diff --git a/docs/delete/index.html b/docs/delete/index.html new file mode 100644 index 0000000..892497b --- /dev/null +++ b/docs/delete/index.html @@ -0,0 +1,574 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Delete - Yq + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + +
    +
    +
    + + +
    +
    +
    + + +
    +
    + + + + + +

    Delete

    + +
    yq d <yaml_file|json_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:
    +  c: 2
    +  apples: green
    +
    + +

    then

    +
    yq d sample.yaml b.c
    +
    + +

    will output:

    +
    b:
    +  apples: green
    +
    + +

    From STDIN

    +
    cat sample.yaml | yq d - b.c
    +
    + +

    Deleting array elements

    +

    Given a sample.yaml file of:

    +
    b:
    +  c: 
    +    - 1
    +    - 2
    +    - 3
    +
    + +

    then

    +
    yq d sample.yaml 'b.c[1]'
    +
    + +

    will output:

    +
    b:
    +  c:
    +  - 1
    +  - 3
    +
    + +

    Deleting nodes in-place

    +

    Given a sample.yaml file of:

    +
    b:
    +  c: 2
    +  apples: green
    +
    + +

    then

    +
    yq d -i sample.yaml b.c
    +
    + +

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

    +

    Keys with dots

    +

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

    +
    b:
    +  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.

    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index e17b9a6..34111b6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -274,6 +274,18 @@ +
  • + + Delete + +
  • + + + + + + +
  • Create diff --git a/docs/merge/index.html b/docs/merge/index.html index 91d5b6f..c8007d9 100644 --- a/docs/merge/index.html +++ b/docs/merge/index.html @@ -238,6 +238,18 @@ +
  • + + Delete + +
  • + + + + + + +
  • Create diff --git a/docs/read/index.html b/docs/read/index.html index 8e3f446..07097b2 100644 --- a/docs/read/index.html +++ b/docs/read/index.html @@ -305,6 +305,18 @@ +
  • + + Delete + +
  • + + + + + + +
  • Create diff --git a/docs/search/search_index.json b/docs/search/search_index.json index 4ce506e..6fd6408 100644 --- a/docs/search/search_index.json +++ b/docs/search/search_index.json @@ -95,6 +95,36 @@ "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.", "title": "Keys with dots" }, + { + "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.", + "title": "Delete" + }, + { + "location": "/delete/#to-stdout", + "text": "Given a sample.yaml file of: b:\n c: 2\n apples: green then yq d sample.yaml b.c will output: b:\n apples: green", + "title": "To Stdout" + }, + { + "location": "/delete/#from-stdin", + "text": "cat sample.yaml | yq d - b.c", + "title": "From STDIN" + }, + { + "location": "/delete/#deleting-array-elements", + "text": "Given a sample.yaml file of: b:\n c: \n - 1\n - 2\n - 3 then yq d sample.yaml 'b.c[1]' will output: b:\n c:\n - 1\n - 3", + "title": "Deleting array elements" + }, + { + "location": "/delete/#deleting-nodes-in-place", + "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/#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.", + "title": "Keys with dots" + }, { "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.", diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 1fb0779..736dac6 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -4,7 +4,7 @@ / - 2018-02-28 + 2018-05-07 daily @@ -12,7 +12,7 @@ /read/ - 2018-02-28 + 2018-05-07 daily @@ -20,7 +20,15 @@ /write/ - 2018-02-28 + 2018-05-07 + daily + + + + + + /delete/ + 2018-05-07 daily @@ -28,7 +36,7 @@ /create/ - 2018-02-28 + 2018-05-07 daily @@ -36,7 +44,7 @@ /convert/ - 2018-02-28 + 2018-05-07 daily @@ -44,7 +52,7 @@ /merge/ - 2018-02-28 + 2018-05-07 daily diff --git a/docs/write/index.html b/docs/write/index.html index 2e4d65a..dbf82f0 100644 --- a/docs/write/index.html +++ b/docs/write/index.html @@ -319,6 +319,18 @@ +
  • + + Delete + +
  • + + + + + + +
  • Create @@ -603,13 +615,13 @@ b.e[0].name: Howdy Partner -