O que eu fiz?
[root@mdfdevha1 ~]# Group_ID='/opt/keycloak/bin/kcadm.sh get groups -r TEST'
[root@mdfdevha1 ~]# echo $Group_ID
[ { "id" : "57c86153-11ba-4d19-aafb-9903ee00086b", "name" : "Admin_UserGroup", "path" : "/Admin_UserGroup", "subGroups" : [ ] } ]
[root@mdfdevha1 ~]# SURE_USER_ID='echo $Group_ID | cut -d : -f2 | awk -F\" '{print $2}''
[root@mdfdevha1 ~]# echo $SURE_USER_ID
57c86153-11ba-4d19-aafb-9903ee00086b
Nesse caso, posso obter o id, mas minha exigência é um pouco complexa
Eu corro abaixo do comando
[root@mdfdevha1 ~]# Group_ID='/opt/keycloak/bin/kcadm.sh get groups -r My_Realm'
e depois
[root@mdfdevha1 ~]# echo $Group_ID
A saída foi um registro múltiplo no formato JSON
[ { "id" : "e27206c0-aeb6-43db-acda-c4ba43233071", "name" : "A1", "path" : "/A1", "subGroups" : [ ] },
{ "id" : "89f3bd6a-33a9-4e02-9fe3-eae660c5a6cf", "name" : "Admin_UserGroup", "path" : "/Admin_UserGroup", "subGroups" : [ ] },
{ "id" : "cdc2bce5-c3bb-4b88-bdaf-d87b8bb6c644", "name" : "Group104", "path" : "/Group104", "subGroups" : [ ] },
{ "id" : "a0d749f2-ab6c-4c27-ad55-3357eaab9527", "name" : "Group105", "path" : "/Group105", "subGroups" : [ ] },
{ "id" : "fbf99c34-d50d-408b-8d19-9713f9af3e3a", "name" : "Group106", "path" : "/Group106", "subGroups" : [ ] },
{ "id" : "ebd8336f-4017-4fb1-8035-153ae1d9ba37", "name" : "Group201", "path" : "/Group201", "subGroups" : [ ] },
{ "id" : "38f4aef7-caf0-4430-9e61-1ae7026e872f", "name" : "Group202", "path" : "/Group202", "subGroups" : [ ] },
{ "id" : "436a0f4a-8b1b-4d7d-a014-fcec3513644e", "name" : "Group203", "path" : "/Group203", "subGroups" : [ ] },
{ "id" : "41962c5f-e7e9-4748-b81f-e3f1880b78de", "name" : "Sure_Groups", "path" : "/Sure_Groups", "subGroups" : []}]
Agora, da saída acima, quero obter o ID
, em que name = Admin_UserGroup
.
Como isso pode acontecer?