Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Jul 1999 00:37:51 +0200
From:      Ollivier Robert <roberto@keltia.freenix.fr>
To:        freebsd-hackers@FreeBSD.org
Subject:   Re: Was someone looking for a BSD licensed stat(1)?
Message-ID:  <19990729003751.A41102@keltia.freenix.fr>
In-Reply-To: <19990728162436.D29649@homer.louisville.edu>; from Keith Stevenson on Wed, Jul 28, 1999 at 04:24:36PM -0400
References:  <19990728154654.A26747@homer.louisville.edu> <Pine.BSF.4.10.9907281558350.92555-100000@janus.syracuse.net> <19990728162436.D29649@homer.louisville.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
According to Keith Stevenson:
> Sure, I can work on that.  It would be helpful if you could include a few
> sample outputs that I could work from.

You may also want to look at the builtin stat(1) function in zsh too. 3.1.5+
only, I don't think 3.1.4 had it. BTW 3.1.6 now pretty close to release.

       stat [ -gnNlLtTrs ] [ -f fd ] [ -H hash ] [ -A array ] [
              -F fmt ] [ +element ] [ file ... ]
              The command acts as a front end to the stat  system
              call  (see  stat(2)).   If the stat call fails, the
              appropriate system error message printed and status
              1  is  returned.   The  fields  of struct stat give
              information about the files provided  as  arguments
              to  the  command.   In  addition to those available
              from the stat call, an extra element `link' is pro-
              vided.  These elements are:

              device The  number  of the device on which the file
                     resides.

              inode  The unique number of the file on this device
                     (`inode' number).

              mode   The  mode  of  the file; that is, the file's
                     type and access permissions.   With  the  -s
                     option,  this  will  be returned as a string
                     corresponding to the  first  column  in  the
                     display of the ls -l command.

              nlink  The number of hard links to the file.

              uid    The  user ID of the owner of the file.  With
                     the -s option, this is displayed as  a  user
                     name.

              gid    The  group  ID  of  the  file.   With the -s
                     option, this is displayed as a group name.

              rdev   The raw device number.  This is only  useful
                     for special devices.

              size   The size of the file in bytes.

              atime
              mtime
              ctime  The  last  access,  modification  and  inode
                     change times of the file,  respectively,  as
                     the  number of seconds since midnight GMT on
                     1st January,  1970.   With  the  -s  option,
                     these  are  printed as strings for the local
                     time zone; the format can  be  altered  with
                     the  -F  option,  and with the -g option the
                     times are in GMT.

              blksize
                     The number of bytes in one allocation  block
                     on the device on which the file resides.

              block  The  number of disk blocks used by the file.

              link   If the file is a link and the -L  option  is
                     in  effect,  this  contains  the name of the
                     file linked to, otherwise it is empty.  Note
                     that  if  this  element  is selected (``stat
                     +link'') then the -L option is automatically
                     used.

              A  particular  element may be selected by including
              its name preceded by a `+' in the option list; only
              one  element is allowed.  The element may be short-
              ened to any unique set of leading characters.  Oth-
              erwise, all elements will be shown for all files.
              Options:

              -A array
                     Instead  of  displaying the results on stan-
                     dard output, assign them to  an  array,  one
                     struct  stat  element  per array element for
                     each file in order.  In  this  case  neither
                     the  name of the element nor the name of the
                     files  is  provided  unless  the  -t  or  -n
                     options  are provided, respectively.  In the
                     former case the element name  appears  as  a
                     prefix  to the appropriate array element and
                     in the latter case the file name appears  as
                     a  separate  array element preceding all the
                     others.   Other   formatting   options   are
                     respected.

              -H hash
                     Similar to -A, but instead assign the values
                     to hash.  The keys are the  elements  listed
                     above.   If  the  -n option is provided then
                     the name of the file is included in the hash
                     with key name.

              -f fd  Use  the  file on file descriptor fd instead
                     of named files; no list  of  file  names  is
                     allowed in this case.

              -F fmt Supplies a strftime (see strftime(3)) string
                     for the formatting  of  the  time  elements.
                     The -s option is implied.

              -g     Show the time elements in the GMT time zone.
                     The -s option is implied.

              -l     List the names  of  the  type  elements  (to
                     standard  output or an array as appropriate)
                     and return immediately; options  other  than
                     -A and arguments are ignored.

              -L     Perform  an lstat (see lstat(2)) rather than
                     a stat system call.  In this  case,  if  the
                     file  is  a link, information about the link
                     itself  rather  than  the  target  file   is
                     returned.   This  option is required to make
                     the link element useful.

              -n     Always show the  names  of  files.   Usually
                     these are only shown when output is to stan-
                     dard output and there is more than one  file
                     in the list.

              -N     Never show the names of files.

              -r     Print  raw  data (the default format) along-
                     side string data (the -s format); the string
                     data  appears  in  parentheses after the raw
                     data.

              -s     Print mode, uid, gid and the three time ele-
                     ments  as  strings  instead  of numbers.  In
                     each case the format is like that of ls  -l.

              -t     Always  show the type names for the elements
                     of struct  stat.   Usually  these  are  only
                     shown  when output is to standard output and
                     no individual element has been selected.

              -T     Never show the type names of the struct stat
                     elements.
-- 
Ollivier ROBERT -=- FreeBSD: The Power to Serve! -=- roberto@keltia.freenix.fr
FreeBSD keltia.freenix.fr 4.0-CURRENT #72: Mon Jul 12 08:26:43 CEST 1999



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990729003751.A41102>