Subject: Re: stat(1)
To: Jeremy C. Reed <reed@reedmedia.net>
From: Eric Haszlakiewicz <erh@nimenees.com>
List: current-users
Date: 12/24/2001 20:55:15
On Mon, Dec 24, 2001 at 03:09:29AM -0800, Jeremy C. Reed wrote:
> On Sun, 23 Dec 2001, Eric Haszlakiewicz wrote:
>
> > I remember a while ago someone saying that a stat command might be
> > useful.
>
> I started writing one myself, but I never could decide on the format it
> should output. I think I saw two others mentioned also.
I used the order of the stat structure with each column separated by
tabs. (since some fields, like the date, contain spaces) After I wrote it
I found the linux stat command (but not any others). Perhaps it would be
useful to match that.
> > I didn't see anyone say they were writing one, so I did. I'm not done with
>
> Can you send some usage examples and output?
Sure. I tried to make the short options as obvious as possible. Long options
(--foo) use a field name from the stat structure. The order of the columns is
the order of the stat structure:
Usage: stat [-LqQansbftugl] [-mA | -m[u][g][o][s]] [-TA | -T[a][m][c]] file [...]
stat [-LqQ] [--fieldname] file [...]
So very quiet output using lstat to get blocks used, uid and user modes would be:
stat -LQbu -mu foo
resulting in:
rw- erh 120288
Without -Q:
MODE UID BLOCKS
foo: rw- erh 120288
Or add a -n to get numerical output: (stat -nLbu -mu foo)
0x8184 101 120288
(whoops, didn't mask that mode right. like I said, not finished yet)
default output: (stat foo)
TYPE MODE UID GID SIZE
foo: REG rw-r--r-- erh wheel 61559863
Or, specify fields of the stat structure: (stat --st_nlink --st_size foo)
LINKS SIZE
foo: 1 61559863
> Since, it didn't build for me:
> stat.c:317: warning: implicit declaration of function `getprogname'
> (I guess I should have tried this under a newer NetBSD, especially since
> this was posted to the current list.)
uh, yeah. :) Hasn't getprogname() been present for a while now? I'm running
current as of Dec 1 and as of yet I haven't tried anything earlier.
eric