[BBLISA] Re: File::Stat from Bourne or Bash (fwd)

bblisa at richfox.org bblisa at richfox.org
Mon Aug 15 11:53:53 EDT 2005


Hi,

Adam Moskowitz mentioned:

>> D'oh! There does appear to be a stat command.
>> I'm not sure about how widely distributed it is.
>
>Well, it's not part of any standard I know of, so at best it's going to
>be hit-or-miss.
>
>> a shell command that gives **parsable output**
>
>I'd hardly call the output you showed "parseable." 

This is certainly true. These examples aren't particularly clear about how
the formatting is easily parsed. The linux command allows the user to
specify a format on the command line, much like strftime.
The BSD derivatives that incorporate the NetBSD 1.6 version of
stat(1) include the option "-s" which does:

     -s      Display information in ``shell output'', suitable for
		initializing variables.

-bash-2.05b$ stat -s dead.letter 
st_dev=1043 st_ino=1109817 st_mode=0100600 st_nlink=1 st_uid=1001
st_gid=1001 st_rdev=4445012 st_size=310 st_atime=1123786812
st_mtime=1123333452 st_ctime=1123333452 st_birthtime=1123333452
st_blksize=16384 st_blocks=4 st_flags=0

One of the things I was hoping to do was to write a shell script that I
could drop onto any system and have it figure out what system it was on
and use the appropriate execution path, which was one reason I didn't
want to write my own shell-callable stat program.

Thanks,
Rich.

On Mon, 15 Aug 2005 bblisa at richfox.org wrote:

> Hi,
> 
> D'oh! There does appear to be a stat command.
> I'm not sure about how widely distributed it is. At least under FreeBSD
> it's available under the linux compatibility package and on my
> (4.2) installation it's at: /usr/compat/linux/usr/bin/stat
> Anyways, the version I have returns output such as:
> 
> bash-2.04$ /usr/compat/linux/usr/bin/stat switchpitch.txt 
>   File: "switchpitch.txt"
>   Size: 2300         Filetype: Regular File
>   Mode: (0664/-rw-rw-r--)         Uid: ( 1001/    rich)  Gid: (    0/
> wheel)
> Device: 116,5   Inode: 1500545   Links: 1    
> Access: Sat Aug  6 17:20:23 2005(00008.15:52:06)
> Modify: Thu Jul 14 08:54:52 2005(00032.00:17:37)
> Change: Thu Jul 14 08:54:52 2005(00032.00:17:37)
[snip]






More information about the bblisa mailing list