Subject: Re: stat(1)
To: Robert Elz <kre@munnari.OZ.AU>
From: Andrew Brown <firstname.lastname@example.org>
Date: 12/29/2001 00:45:05
> | Mine only puts out the times -- inode and size are easy enough to get
> | from ls, as are owner and group. To me, the important thing is a
> | format that's easily parseable by scripts.
>Exactly. No-one really needs an even more verbose "ls" output. Though
>parsing ls output is never really what one ought to be doing, it is too
>likely to undergo random changes to make it "look better".
what if...what if someone were to use up another option letter for ls
and allow the user to specify a "format" (sort in the same way that
date and ps allow user specified formatting)? hmm...-O looks unused. :)
>So mine prints exactly whatever is asked for in whatever format is requested
>(though I've yet to add a way to give it strftime formats for date printing).
i wrote one once so that i could see more stuff. then i wrote another
today because i read this thread. then i realized i could emulate my
old script using my new one, and even ls (ls -lfdT actually, with -F
and -L as options, and perhaps without -T).
>Alternatively (to make things really easy for scripts), it prints everything
>in the form of var assignments (eval `stat -g file`) using mostly numeric
>output rather than symbolic.
a reasonable formatting grammar could do that also. to use myself as
% stat stat
6 164676 100755 1 204 20 669392 5908 1009604500 1009604399 1009604399 8192 12 stat
% stat -f "set atime=%at;set ctime=%ct;set mtime=%mt" stat
set atime=1009604407;set ctime=1009604399;set mtime=1009604399
% eval `./stat -f "set atime=%at;set ctime=%ct;set mtime=%mt" stat`
% echo $mtime $ctime $atime
1009604399 1009604399 1009604425
admittedly, i wrote it in perl (so i don't get all the struct stat
fields), and the format parser is "crude", but it works well enough to
make me happy.
|-----< "CODE WARRIOR" >-----|
email@example.com * "ah! i see you have the internet
firstname.lastname@example.org (Andrew Brown) that goes *ping*!"
email@example.com * "information is power -- share the wealth."