mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-05 09:04:58 +08:00
v4.43.1
This commit is contained in:
@@ -56,6 +56,40 @@ IFS= read -rd '' output < <(cat my_file)
|
||||
output=$output ./yq '.data.values = strenv(output)' first.yml
|
||||
```
|
||||
|
||||
## Interpolation
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
value: things
|
||||
another: stuff
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq '.message = "I like \(.value) and \(.another)"' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
value: things
|
||||
another: stuff
|
||||
message: I like things and stuff
|
||||
```
|
||||
|
||||
## Interpolation - not a string
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
value:
|
||||
an: apple
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq '.message = "I like \(.value)"' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
value:
|
||||
an: apple
|
||||
message: 'I like an: apple'
|
||||
```
|
||||
|
||||
## To up (upper) case
|
||||
Works with unicode characters
|
||||
|
||||
@@ -383,3 +417,32 @@ will output
|
||||
- word
|
||||
```
|
||||
|
||||
## To string
|
||||
Note that you may want to force `yq` to leave scalar values wrapped by passing in `--unwrapScalar=false` or `-r=f`
|
||||
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
- 1
|
||||
- true
|
||||
- null
|
||||
- ~
|
||||
- cat
|
||||
- an: object
|
||||
- - array
|
||||
- 2
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq '.[] |= to_string' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
- "1"
|
||||
- "true"
|
||||
- "null"
|
||||
- "~"
|
||||
- cat
|
||||
- "an: object"
|
||||
- "- array\n- 2"
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user