jmespath.site icon indicating copy to clipboard operation
jmespath.site copied to clipboard

How to remove duplicates in the az command output using --query

Open praveenambati1233 opened this issue 3 years ago • 2 comments

Command - az resource list --resource-group MYRG --query "[].{type:type}" output - [ { "type": "Microsoft.Network/networkInterfaces" }, { "type": "Microsoft.Network/networkInterfaces" }, { "type": "Microsoft.Network/networkSecurityGroups" }, { "type": "Microsoft.Network/networkSecurityGroups" } ]

praveenambati1233 avatar Aug 11 '21 18:08 praveenambati1233

mark

abeelan avatar Dec 02 '21 02:12 abeelan

Case #88 - Solution

Hi, hope you are well

  • if you are using powershell follow this command
az resource list -g MYRG --query  "[].{Type:type}" -o tsv | get-unique -AsString 
  • if you are using az cli in linux "Bash"
az resource list -g MYRG --query  "[].{Type:type}" -o tsv | sort | uniq

I hope I could help you, if you have any doubts, please let me know

Didjacome avatar Jul 25 '22 08:07 Didjacome