Perl version of stat


While messing around with Perl, I created a Perl program that displays output similar to the Linux stat utility:

$ stat.pl /etc/services /etc/passwd /etc/shadow /etc/shadow-

File: /etc/services
Size: 15 Blocks: 2 Block Size: 8192
Device: 22282240 Inode: 7876 Links: 1
Perms: 777 Uid: ( 0 / root ) Gid: ( 0 / root )
Access Time (mtime) : Tue Sep 13 18:48:34 2005
Change Time (ctime) : Mon Aug 15 22:48:37 2005
Modification Time (mtime): Mon Aug 15 22:48:37 2005

File: /etc/passwd
Size: 725 Blocks: 2 Block Size: 8192
Device: 22282240 Inode: 9021 Links: 1
Perms: 644 Uid: ( 0 / root ) Gid: ( 0 / root )
Access Time (mtime) : Tue Sep 13 18:50:51 2005
Change Time (ctime) : Tue Aug 16 00:25:09 2005
Modification Time (mtime): Tue Aug 16 00:25:09 2005

File: /etc/shadow
Size: 376 Blocks: 2 Block Size: 8192
Device: 22282240 Inode: 10176 Links: 1
Perms: 400 Uid: ( 0 / root ) Gid: ( 0 / root )
Access Time (mtime) : Tue Sep 13 18:50:51 2005
Change Time (ctime) : Tue Aug 16 00:25:18 2005
Modification Time (mtime): Tue Aug 16 00:25:18 2005

This will be a useful little utility once I cleanup the Perms and Device lines. :)

This article was posted by Matty on 2005-09-13 19:18:00 -0400 -0400