~/bin/stat

What have you always wanted on the command line?

stat? i: hear; you cry! (insert more [silly] {punctuation} around ‘ere!)

I present, to you, my ~/bin/stat

#!/usr/bin/perl
use POSIX qw(strftime);

my $FORMAT="%H:%M %a, %e %b %y";

foreach(@ARGV)
{
  my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
      $atime,$mtime,$ctime,$blksize,$blocks)
      = stat($_);
  print $_."\n";
  print "Dev:   $dev\n";
  print "inode: $ino\n";
  print "mode:  $mode\n";
  print "nlink: $nlink\n";
  print "uid:   $uid\n";
  print "gid:   $gid\n";
  print "rdev:  $rdev\n";
  print "size:  $size\n";
  print "atime: ".strftime($FORMAT,localtime($atime))."\n";
  print "mtime: ".strftime($FORMAT,localtime($mtime))."\n";
  print "ctime: ".strftime($FORMAT,localtime($ctime))."\n";
  print "blksz: $blksize\n";
  print "blks:  $blocks\n\n";
}

it’ll make it to junkcode sometime soon.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.