mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
v4.27.3 updates
This commit is contained in:
parent
8c2488d25f
commit
05ee3403ca
@ -7,6 +7,11 @@ Which will assign the LHS node values to the RHS node values. The RHS expression
|
|||||||
|
|
||||||
### relative form: `|=`
|
### relative form: `|=`
|
||||||
This will do a similar thing to the plain form, however, the RHS expression is run against _the LHS nodes_. This is useful for updating values based on old values, e.g. increment.
|
This will do a similar thing to the plain form, however, the RHS expression is run against _the LHS nodes_. This is useful for updating values based on old values, e.g. increment.
|
||||||
|
|
||||||
|
|
||||||
|
### Flags
|
||||||
|
- `c` clobber custom tags
|
||||||
|
|
||||||
{% hint style="warning" %}
|
{% hint style="warning" %}
|
||||||
Note that versions prior to 4.18 require the 'eval/e' command to be specified. 
|
Note that versions prior to 4.18 require the 'eval/e' command to be specified. 
|
||||||
|
|
||||||
@ -235,3 +240,37 @@ a:
|
|||||||
- bogs
|
- bogs
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Custom types are maintained by default
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: !cat meow
|
||||||
|
b: !dog woof
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq '.a = .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: !cat woof
|
||||||
|
b: !dog woof
|
||||||
|
```
|
||||||
|
|
||||||
|
## Custom types: clovver
|
||||||
|
Use the `c` option to clobber custom tags
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: !cat meow
|
||||||
|
b: !dog woof
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq '.a =c .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: !dog woof
|
||||||
|
b: !dog woof
|
||||||
|
```
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ You can control how objects are merged by using one or more of the following fla
|
|||||||
- `d` deeply merge arrays
|
- `d` deeply merge arrays
|
||||||
- `?` only merge _existing_ fields
|
- `?` only merge _existing_ fields
|
||||||
- `n` only merge _new_ fields
|
- `n` only merge _new_ fields
|
||||||
|
- `c` clobber custom tags
|
||||||
|
|
||||||
|
|
||||||
### Merge two files together
|
### Merge two files together
|
||||||
@ -481,3 +482,26 @@ b: !goat
|
|||||||
dog: woof
|
dog: woof
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Custom types: clobber tags
|
||||||
|
Use the `c` option to clobber custom tags. Note that the second tag is now used
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: !horse
|
||||||
|
cat: meow
|
||||||
|
b: !goat
|
||||||
|
dog: woof
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq '.a *=c .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: !goat
|
||||||
|
cat: meow
|
||||||
|
dog: woof
|
||||||
|
b: !goat
|
||||||
|
dog: woof
|
||||||
|
```
|
||||||
|
|
||||||
|
@ -112,6 +112,26 @@ will output
|
|||||||
cat; meow; 1; ; true
|
cat; meow; 1; ; true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Trim strings
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- ' cat'
|
||||||
|
- 'dog '
|
||||||
|
- ' cow cow '
|
||||||
|
- horse
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq '.[] | trim' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
cat
|
||||||
|
dog
|
||||||
|
cow cow
|
||||||
|
horse
|
||||||
|
```
|
||||||
|
|
||||||
## Match string
|
## Match string
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
|
Loading…
Reference in New Issue
Block a user