How can I find the group id (gid) for the sdcard_r group on android? The question says it all. All folders on my sdcard has owner set as 0(root) and group set as sdcard_r - means all apps that have permissions to access the sdcard.

However, since I have root, I want to change the group of this folder using chgrp, so that only a selected app can access this. I know how to do this too, so no probs until now.

However, I don't want this to be a one-way setting, I want to be able to revert back to sdcard_r in case something goes wrong. Now I don't know the actual gid of this group sdcard_r and chgrp only works with gids, not names. So, how can I find the gid of this group, sdcard_r?
Use the following command to see GID of the concerned group:

id -G group_name

Courtesy of this answer of doylefermi. 

It is very much possible that the GID would be 1028 given this line in source code of Android.