This commit is contained in:
Mike Farah
2025-05-09 14:55:05 +10:00
parent 2c7cce0878
commit 6c0f296574
8 changed files with 47 additions and 49 deletions
+1 -1
View File
@@ -232,7 +232,7 @@ yq '.a += "3h10m"' sample.yml
```
will output
```yaml
a: 2021-01-01T03:10:00Z
a: 2021-01-01T00:00:00Z3h10m
```
## Date addition - custom format
@@ -248,12 +248,6 @@ then
yq 'explode(.f)' sample.yml
```
will output
```yaml
f:
a: cat
cat: b
```
## Explode with merge anchors
Given a sample.yml file of:
```yaml
+5 -8
View File
@@ -152,7 +152,7 @@ will output
fc: ""
- p: name.0
isKey: false
hc: under-name-comment
hc: ""
lc: ""
fc: ""
```
@@ -172,7 +172,7 @@ yq '.name[0] | headComment' sample.yml
```
will output
```yaml
under-name-comment
```
## Set head comment
@@ -258,7 +258,7 @@ yq '... comments=""' sample.yml
will output
```yaml
a: cat
b:
b: null
```
## Get line comment
@@ -293,7 +293,6 @@ yq '. | head_comment' sample.yml
```
will output
```yaml
welcome!
```
@@ -313,8 +312,7 @@ yq 'head_comment' sample.yml
```
will output
```yaml
welcome!
bob
```
## Get foot comment
@@ -333,7 +331,6 @@ yq '. | foot_comment' sample.yml
```
will output
```yaml
have a great day
no really
```
+1 -5
View File
@@ -170,7 +170,7 @@ yq '.a += "3h10m"' sample.yml
```
will output
```yaml
a: 2021-01-01T03:10:00Z
a: 2021-01-01T00:00:00Z3h10m
```
## Date subtraction
@@ -185,10 +185,6 @@ then
yq '.a -= "3h10m"' sample.yml
```
will output
```yaml
a: 2021-01-01T00:00:00Z
```
## Date addition - custom format
Given a sample.yml file of:
```yaml
+1 -1
View File
@@ -109,7 +109,7 @@ yq '.a.x | key | headComment' sample.yml
```
will output
```yaml
comment on key
```
## Check node is a key
-4
View File
@@ -105,10 +105,6 @@ then
yq '.a -= "3h10m"' sample.yml
```
will output
```yaml
a: 2021-01-01T00:00:00Z
```
## Date subtraction - custom format
Use with_dtf to specify your datetime format. See [date-time operators](https://mikefarah.gitbook.io/yq/operators/date-time-operators) for more information.