First, a bit of background to explain what's going on: Files in OS X can have two quite different kinds of permission settings applied to them: POSIX and ACLs.
Files always (well, almost always) have POSIX permissions applied, consisting of an owner, group, and others (with some combination of read, write, and execute for each of those). There is no way to control inheritance of POSIX permissions: new items are always owned by whatever user created them, the group assignment is inherited from the folder they're in, and the access is determined by the umask (which is pretty much always: owner gets full access, group and others read only + execute for folders). So POSIX permissions won't work for what you're trying to do.
Files can also have an access control list (ACL) applied. This is a list of access control entries (ACEs), each of which applies to a user or group, specifies types of access (in great detail), whether they're being allowed or denied, and whether the ACE should also be copied to items created inside the folder. That last bit is the part that makes this useful for you; you need to create an ACE on the folder that specifies the group you want, the types of access you want, and full inheritance.
chmod on OS X can manipulate ACEs with the +a, -a, etc permissions options. If I understand what you want, you'd use this (with your group name and folder path substituted) to create the ACE:
chmod +a "group:examplegroup allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit" /path/to/folder
Note that the inheritance is not "live", i.e. it doesn't apply to items created before you assigned the ACE, and it doesn't apply to items created somewhere else and then moved into the folder. You can apply it to existing contents by using -R (chmod -R +a ...
). I don't know of a way (except Apple's server admin tools) to force inheritance to items moved into the folder.
Best Answer
The command you posted has two parts
find /Volumes/Documents/ -exec stat -f "%N %Sm" {} +
>~/Desktop/test.txt
The second part is easier to explain, it just writes all the output of the first one into a file called
test.txt
which is stored on your desktop. If you leave that part out, the result offind
will be directly written into your Terminal window.The first part is the actual
find
command. A call tofind
basically gets two kinds of parameters/Volumes/Documents/
in your case)A simple version would look like
find /Volumes/Documents/ -print
which just prints every file/folder found.In your example the expression part is a bit more elaborated:
-exec
runs a command on the results of find (stat -f "%N %Sm"
actually)stat
gives info about a file.The
-f
option for stat displays information using a specified format.%N %Sm
is the format used by-f
.%
means a format string.N
means to print the file name.Sm
means to print the date modified for the file.{} +
is replaced by as many found files/as possible in each call tostat
For more information on understanding commands, see the man page for
find
andstat
.