On 6/20/2025 8:15 AM, Sebastian Feld via Cygwin wrote:
Does Cygwin or POSIX have a tool to test whether a file is owned by a
specific group?

Win32, like Linux and POSIX, has the concept that files have an owner,
and a group 
(ref:https://learn.microsoft.com/en-us/windows/win32/api/aclapi/nf-aclapi-getsecurityinfo).

How can I test whether a file is owned by a given group name, or not?
/usr/bin/test -g and -G do not help because they only look and gid,
egid. But I want to pass the group's name as an argument.

With some help from the web, I found this:

  find foo -prune -printf '%g\n'

This prints the group name, giving a gid only if it can't find the name of the 
group

Also this:

  stat --format=%G foo

Then you can compare the result against the group you have in mind.

I found this all out with web search and running a few quick tests under cygwin.

Regards - Eliot Moss

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to