jmespath.site
jmespath.site copied to clipboard
How to remove duplicates in the az command output using --query
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" } ]
mark
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