yq/docs/search/search_index.json

1 line
32 KiB
JSON
Raw Normal View History

2019-05-16 04:57:34 +00:00
{"config":{"lang":["en"],"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"yq \u00b6 yq is a lightweight and portable command-line YAML processor The aim of the project is to be the jq or sed of yaml files. Install \u00b6 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 sudo apt update sudo apt install yq -y or, Download latest binary or alternatively: go get gopkg.in/mikefarah/yq.v2 View on GitHub","title":"Install"},{"location":"#yq","text":"yq is a lightweight and portable command-line YAML processor The aim of the project is to be the jq or sed of yaml files.","title":"yq"},{"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 sudo apt update sudo apt install yq -y or, Download latest binary or alternatively: go get gopkg.in/mikefarah/yq.v2 View on GitHub","title":"Install"},{"location":"convert/","text":"Yaml to Json \u00b6 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 then yq r -j sample.yaml b.c will output {\"b\":{\"c\":2}} Json to Yaml \u00b6 To read in json, just pass in a json file instead of yaml, it will just work :) e.g given a json file {\"a\":\"Easy! as one two three\",\"b\":{\"c\":2,\"d\":[3,4]}} then yq r sample.json will output a: Easy! as one two three b: c: 2 d: - 3 - 4","title":"Convert"},{"location":"convert/#yaml-to-json","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: c: 2 then yq r -j sample.yaml b.c will output {\"b\":{\"c\":2}}","title":"Yaml to Json"},{"location":"convert/#json-to-yaml","text":"To read in json, just pass in a json file instead of yaml, it will just work :) e.g given a json file {\"a\":\"Easy! as one two three\",\"b\":{\"c\":2,\"d\":[3,4]}} then yq r sample.json will output a: Easy! as one two three b: c: 2 d: - 3 - 4","title":"Json to Yaml"},{"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. Currently this does not support creating multiple documents in a single yaml file. yq n <path> <new value> Creating a simple yaml file \u00b6 yq n b.c cat will output: b: c: cat Creating using a create script \u00b6 Create scripts follow the same format as the update scripts. Given a script create_instructions.yaml of: b.c: 3 b.e[+].name: Howdy Partner then yq n -s create_instructions.yaml will output: b: c: 3 e: - name: Howdy Partner You can also pipe the instructions in: cat create_instructions.yaml | yq n -s - Keys with dots \u00b6 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. Keys (and values) with leading dashes \u00b6 If a key or value has leading dashes, yq won't know that you are passing a value as opposed to a flag (and you will get a 'bad flag syntax' error). To fix that, you will need to tell it to stop processing flags by adding '--' after the last flag like so: yq n -t -- --key --value Will result in ` --key: --value","title":"Create"},{"location":"create/#creating-a-simple-yaml-file","text":"yq n b.c cat will output: b: c: cat","title":"Creating a simple yaml file"},{"location":"create/#creating-using-a-create-script","text":"Create scripts follow the same format as the update scripts. Given a script create_instructions.yaml of: b.c: 3 b.e[+].name: Howdy Partner then yq n -s create_instructions.yaml will output: b: c: 3 e: - name: Howdy Partner You can also pipe the instructions in: cat