Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get unique values in array in a jmespath query?

In an aws cli jmespath query, with for example the output ["a","a","b","a","b"], how do i extract the unique values of it to get ["a","b"]?

like image 375
xor Avatar asked May 04 '16 08:05

xor


1 Answers

It's not what you asked for but I've used the following:

aws ... | jq -r ".[]" | sort | uniq

This will convert ["a", "a", "b", "a"] to:

a
b
like image 94
mekazu Avatar answered Oct 13 '22 07:10

mekazu