> the trick nicely (but is too ``complicated'', and I'd still like
> having a tool that allows userland to call stat/fstat(2):

You are not alone; a number of stat(1) commands seemed to
have popped up over the years.  My friend @ SGI told me IRIX
also has such a command.  I liked its options so I modified
mine to match its options as well as kept the option to
specify output format.

New options:

-a atime
-c ctime
-d dev
-g group
-i inode
-k kind (dir/file/fifo/symlnk/char/block/socket/whiteout)
-l links
-m mtime
-p permissions
-r rdev
-s size
-t all three times
-u user

-q quite (print numeric values, no syntactic sugar)
-f <fd> fstat on file descr. <fd>

For BSD stuff I added

-F flags
-G generation
-b blocks
-B blocksize

Also,
-L use lstat instead of stat
-n print name
-% <fmt> user specified format

<fmt> specification as shown in my previous email, except use
%k for kind and %t for printing all three times.

By default it prints all the stat fields instead of mimicing
"ls -lTd" as before.  You can specify STATFMT env. var for
a default format.

Example:

$ stat -p stat
rwxr-xr-x
$ stat -p -q stat
755

Not having used SGI's stat command I don't know what output
format it uses.

Paul Herman asks in a separate email if there is a happy
medium.  I don't think so.  One can use ls(1) for a more
human readable format.  stat(1) is really for script use.
Even the -% format is for that (to avoid having to pull out
the ginsu knife of awk/sed/perl for common uses).  About the
best I can do in 300 or so lines of code and that is already
a lot of lines for something like this.

-- bakul

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to