On Wed, Aug 18, 2010 at 2:07 AM, Jan Schenkel <janschen...@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.



Jan,

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:

  base.csv|agarzia|agarzia
  callgraph.dot|agarzia|agarzia
  examples.desktop|agarzia|agarzia

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.

:D



-- 
http://www.andregarzia.com All We Do Is Code.
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to