file owner & group names
andre at andregarzia.com
Wed Aug 18 09:17:41 EDT 2010
On Wed, Aug 18, 2010 at 2:07 AM, Jan Schenkel <janschenkel at yahoo.com> wrote:
> The reason to avoid a shell call to stat is simple: calling it for each
> individual file in a big folder could prove an expensive operation, while a
> simple mapping method should suffice to convert 501 to "janschenkel" when
> you're already using the detailed files.
But you can use a single stat command to list the property for all your
files. Using the format options for the stat call you can tailor the output
of the command to suit your needs of parsing. For example, if all you want
is group information then you can do something along the lines of:
stat --format="%n|%U|%G" <list of files>
for example, look at this usage scenario:
stat --format="%n|%U|%G" base.csv callgraph.dot examples.desktop
the output is:
which is a nice parsable format using cr and pipes. First is the file name,
then the owner name, then the group name.
I think that a single stat call querying multiple files is easier than ls -l
or parsing the detailed files and then checking the /etc/ stuff.
http://www.andregarzia.com All We Do Is Code.
More information about the Use-livecode