mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-01 14:14:52 +08:00
Fix typo (#1222)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Anchor and Alias Operators
|
||||
|
||||
Use the `alias` and `anchor` operators to read and write yaml aliases and anchors. The `explode` operator normalises a yaml file (dereference (or expands) aliases and remove anchor names).
|
||||
Use the `alias` and `anchor` operators to read and write yaml aliases and anchors. The `explode` operator normalizes a yaml file (dereference (or expands) aliases and remove anchor names).
|
||||
|
||||
`yq` supports merge aliases (like `<<: *blah`) however this is no longer in the standard yaml spec (1.2) and so `yq` will automatically add the `!!merge` tag to these nodes as it is effectively a custom tag.
|
||||
|
||||
|
||||
@@ -107,13 +107,13 @@ c: fieldC
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq '(.a, .c) = "potatoe"' sample.yml
|
||||
yq '(.a, .c) = "potato"' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
a: potatoe
|
||||
a: potato
|
||||
b: fieldB
|
||||
c: potatoe
|
||||
c: potato
|
||||
```
|
||||
|
||||
## Update string value
|
||||
@@ -151,7 +151,7 @@ a:
|
||||
```
|
||||
|
||||
## Update deeply selected results
|
||||
Note that the LHS is wrapped in brackets! This is to ensure we dont first filter out the yaml and then update the snippet.
|
||||
Note that the LHS is wrapped in brackets! This is to ensure we don't first filter out the yaml and then update the snippet.
|
||||
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
|
||||
@@ -4,7 +4,7 @@ Encode operators will take the piped in object structure and encode it as a stri
|
||||
|
||||
Note that you can optionally pass an indent value to the encode functions (see below).
|
||||
|
||||
These operators are useful to process yaml documents that have stringified embeded yaml/json/props in them.
|
||||
These operators are useful to process yaml documents that have stringified embedded yaml/json/props in them.
|
||||
|
||||
|
||||
| Format | Decode (from string) | Encode (to string) |
|
||||
|
||||
@@ -81,7 +81,7 @@ true
|
||||
false
|
||||
```
|
||||
|
||||
## Dont match number
|
||||
## Don't match number
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
- 3
|
||||
|
||||
@@ -4,7 +4,7 @@ Use `eval` to dynamically process an expression - for instance from an environme
|
||||
|
||||
`eval` takes a single argument, and evaluates that as a `yq` expression. Any valid expression can be used, beit a path `.a.b.c | select(. == "cat")`, or an update `.a.b.c = "gogo"`.
|
||||
|
||||
Tip: This can be useful way parameterise complex scripts.
|
||||
Tip: This can be useful way parameterize complex scripts.
|
||||
|
||||
{% hint style="warning" %}
|
||||
Note that versions prior to 4.18 require the 'eval/e' command to be specified. 
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Anchor and Alias Operators
|
||||
|
||||
Use the `alias` and `anchor` operators to read and write yaml aliases and anchors. The `explode` operator normalises a yaml file (dereference (or expands) aliases and remove anchor names).
|
||||
Use the `alias` and `anchor` operators to read and write yaml aliases and anchors. The `explode` operator normalizes a yaml file (dereference (or expands) aliases and remove anchor names).
|
||||
|
||||
`yq` supports merge aliases (like `<<: *blah`) however this is no longer in the standard yaml spec (1.2) and so `yq` will automatically add the `!!merge` tag to these nodes as it is effectively a custom tag.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Encode operators will take the piped in object structure and encode it as a stri
|
||||
|
||||
Note that you can optionally pass an indent value to the encode functions (see below).
|
||||
|
||||
These operators are useful to process yaml documents that have stringified embeded yaml/json/props in them.
|
||||
These operators are useful to process yaml documents that have stringified embedded yaml/json/props in them.
|
||||
|
||||
|
||||
| Format | Decode (from string) | Encode (to string) |
|
||||
|
||||
@@ -4,4 +4,4 @@ Use `eval` to dynamically process an expression - for instance from an environme
|
||||
|
||||
`eval` takes a single argument, and evaluates that as a `yq` expression. Any valid expression can be used, beit a path `.a.b.c | select(. == "cat")`, or an update `.a.b.c = "gogo"`.
|
||||
|
||||
Tip: This can be useful way parameterise complex scripts.
|
||||
Tip: This can be useful way parameterize complex scripts.
|
||||
|
||||
@@ -19,4 +19,4 @@ On the RHS there is `<init>`, the starting value of the accumulator and `<block>
|
||||
## yq vs jq syntax
|
||||
Reduce syntax in `yq` is a little different from `jq` - as `yq` (currently) isn't as sophisticated as `jq` and its only supports infix notation (e.g. a + b, where the operator is in the middle of the two parameters) - where as `jq` uses a mix of infix notation with _prefix_ notation (e.g. `reduce a b` is like writing `+ a b`).
|
||||
|
||||
To that end, the reduce operator is called `ireduce` for backwards compatability if a `jq` like prefix version of `reduce` is ever added.
|
||||
To that end, the reduce operator is called `ireduce` for backwards compatibility if a `jq` like prefix version of `reduce` is ever added.
|
||||
|
||||
@@ -19,7 +19,7 @@ On the RHS there is `<init>`, the starting value of the accumulator and `<block>
|
||||
## yq vs jq syntax
|
||||
Reduce syntax in `yq` is a little different from `jq` - as `yq` (currently) isn't as sophisticated as `jq` and its only supports infix notation (e.g. a + b, where the operator is in the middle of the two parameters) - where as `jq` uses a mix of infix notation with _prefix_ notation (e.g. `reduce a b` is like writing `+ a b`).
|
||||
|
||||
To that end, the reduce operator is called `ireduce` for backwards compatability if a `jq` like prefix version of `reduce` is ever added.
|
||||
To that end, the reduce operator is called `ireduce` for backwards compatibility if a `jq` like prefix version of `reduce` is ever added.
|
||||
|
||||
{% hint style="warning" %}
|
||||
Note that versions prior to 4.18 require the 'eval/e' command to be specified. 
|
||||
|
||||
@@ -266,7 +266,7 @@ will output
|
||||
```
|
||||
|
||||
## Test using regex
|
||||
Like jq'q equivalent, this works like match but only returns true/false instead of full match details
|
||||
Like jq's equivalent, this works like match but only returns true/false instead of full match details
|
||||
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
|
||||
@@ -46,7 +46,7 @@ Example taken from [jq](https://stedolan.github.io/jq/manual/#Variable/SymbolicB
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
"posts":
|
||||
- "title": Frist psot
|
||||
- "title": First post
|
||||
"author": anon
|
||||
- "title": A well-written article
|
||||
"author": person1
|
||||
@@ -60,7 +60,7 @@ yq '.realnames as $names | .posts[] | {"title":.title, "author": $names[.author]
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
title: Frist psot
|
||||
title: First post
|
||||
author: Anonymous Coward
|
||||
title: A well-written article
|
||||
author: Person McPherson
|
||||
|
||||
Reference in New Issue
Block a user