mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-06 21:39:21 +00:00
Updating readme
This commit is contained in:
parent
f7f6320e88
commit
eaf26894c1
28
README.md
28
README.md
@ -1,8 +1,8 @@
|
|||||||
# yq
|
# yq
|
||||||
|
|
||||||
a lightweight and portable command-line YAML processor. `yq` uses [jq](https://github.com/stedolan/jq) like syntax but works with yaml files as well as json. It doesn't yet support everything `jq` does - but it does support the most common operations and functions, and more is being added continuously.
|
aa lightweight and portable command-line YAML, JSON, INI and XML processor. `yq` uses [jq](https://github.com/stedolan/jq) like syntax but works with yaml files as well as json, xml, ini, properties, csv and tsv. It doesn't yet support everything `jq` does - but it does support the most common operations and functions, and more is being added continuously.
|
||||||
|
|
||||||
yq is written in go - so you can download a dependency free binary for your platform and you are good to go! If you prefer there are a variety of package managers that can be used as well as docker, all listed below.
|
yq is written in go - so you can download a dependency free binary for your platform and you are good to go! If you prefer there are a variety of package managers that can be used as well as Docker and Podman, all listed below.
|
||||||
|
|
||||||
## Quick Usage Guide
|
## Quick Usage Guide
|
||||||
|
|
||||||
@ -13,10 +13,10 @@ yq '.a.b[0].c' file.yaml
|
|||||||
|
|
||||||
Pipe from STDIN:
|
Pipe from STDIN:
|
||||||
```bash
|
```bash
|
||||||
cat file.yaml | yq '.a.b[0].c'
|
yq '.a.b[0].c' < file.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
Update a yaml file, inplace
|
Update a yaml file, in place
|
||||||
```bash
|
```bash
|
||||||
yq -i '.a.b[0].c = "cool"' file.yaml
|
yq -i '.a.b[0].c = "cool"' file.yaml
|
||||||
```
|
```
|
||||||
@ -27,7 +27,13 @@ NAME=mike yq -i '.a.b[0].c = strenv(NAME)' file.yaml
|
|||||||
```
|
```
|
||||||
|
|
||||||
Merge multiple files
|
Merge multiple files
|
||||||
```
|
```bash
|
||||||
|
# merge two files
|
||||||
|
yq -n 'load("file1.yaml") * load("file2.yaml")'
|
||||||
|
|
||||||
|
# merge using globs:
|
||||||
|
# note the use of `ea` to evaluate all the files at once
|
||||||
|
# instead of in sequence
|
||||||
yq ea '. as $item ireduce ({}; . * $item )' path/to/*.yml
|
yq ea '. as $item ireduce ({}; . * $item )' path/to/*.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -40,6 +46,18 @@ yq -i '
|
|||||||
' file.yaml
|
' file.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Find and update an item in an array:
|
||||||
|
```bash
|
||||||
|
yq '(.[] | select(.name == "foo") | .address) = "12 cat st"'
|
||||||
|
```
|
||||||
|
|
||||||
|
Convert JSON to YAML
|
||||||
|
```bash
|
||||||
|
yq -Poy sample.json
|
||||||
|
```
|
||||||
|
|
||||||
|
See [recipes](https://mikefarah.gitbook.io/yq/recipes) for more examples and the [documentation](https://mikefarah.gitbook.io/yq/) for more information.
|
||||||
|
|
||||||
Take a look at the discussions for [common questions](https://github.com/mikefarah/yq/discussions/categories/q-a), and [cool ideas](https://github.com/mikefarah/yq/discussions/categories/show-and-tell)
|
Take a look at the discussions for [common questions](https://github.com/mikefarah/yq/discussions/categories/q-a), and [cool ideas](https://github.com/mikefarah/yq/discussions/categories/show-and-tell)
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user