mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 05:38:04 +00:00
Updated unique docs
This commit is contained in:
parent
1425d0720e
commit
689c535a29
@ -1,3 +1,4 @@
|
||||
# Unique
|
||||
|
||||
This is used to filter out duplicated items in an array.
|
||||
This is used to filter out duplicated items in an array. Note that the original order of the array is maintained.
|
||||
|
||||
|
@ -9,10 +9,12 @@ Note that versions prior to 4.18 require the 'eval/e' command to be specified.&#
|
||||
{% endhint %}
|
||||
|
||||
## Unique array of scalars (string/numbers)
|
||||
Note that unique maintains the original order of the array.
|
||||
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
- 1
|
||||
- 2
|
||||
- 1
|
||||
- 3
|
||||
- 2
|
||||
```
|
||||
@ -22,8 +24,8 @@ yq 'unique' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
- 1
|
||||
- 2
|
||||
- 1
|
||||
- 3
|
||||
```
|
||||
|
||||
|
@ -6,11 +6,12 @@ import (
|
||||
|
||||
var uniqueOperatorScenarios = []expressionScenario{
|
||||
{
|
||||
description: "Unique array of scalars (string/numbers)",
|
||||
document: `[1,2,3,2]`,
|
||||
expression: `unique`,
|
||||
description: "Unique array of scalars (string/numbers)",
|
||||
subdescription: "Note that unique maintains the original order of the array.",
|
||||
document: `[2,1,3,2]`,
|
||||
expression: `unique`,
|
||||
expected: []string{
|
||||
"D0, P[], (!!seq)::- 1\n- 2\n- 3\n",
|
||||
"D0, P[], (!!seq)::- 2\n- 1\n- 3\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
4.25.1:
|
||||
- Can specify a split expression file #1194
|
||||
- Fixed append map bug when key matches value in existing map #1200
|
||||
- Nicer error message when trying to use merge anchor tags other than maps #1184
|
||||
- Fixed Don't automatically read stdin when the null input flag is used
|
||||
- Added type as an alias for tag #1195
|
||||
- Fixes bug when using write in-place with no expression and multiple files #1193
|
||||
- Can specify a split expression file #1194
|
||||
- Fixed append map bug when key matches value in existing map #1200
|
||||
- Nicer error message when trying to use merge anchor tags other than maps #1184
|
||||
- Fixed Don't automatically read stdin when the null input flag is used
|
||||
- Added type as an alias for tag #1195
|
||||
- Fixes bug when using write in-place with no expression and multiple files #1193
|
||||
|
||||
4.24.5:
|
||||
- Fixed scenarios that dropped the first line if it's a comment (#1181)
|
||||
|
Loading…
Reference in New Issue
Block a user