yq/docs/search/search_index.json

1 line
24 KiB
JSON
Raw Normal View History

2018-11-18 17:40:51 +00:00
{"config":{"lang":["en"],"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"yq 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 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 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 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 yq n b.c cat will output: b: c: cat Creating using a create script Create scripts follow the same format as the update scripts. Given a script create_instructions.yaml of: b.c: 3 b.e[0].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 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.","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[0].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 -","title":"Creating using a create script"},{"location":"create/#keys-with-dots","text":"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.","title":"Keys