#!/bin/sh -- # A comment mentioning perl, to prevent perl from looping. Indented to work with bash. eval 'exec perl -S $0 ${1+"$@"}' if 0; $Type = ''; if ( @ARGV[0] =~ /^-(\w+)$/ ) { $Type = $1; shift; } if ( ! @ARGV || $ARGV[0] eq '-' ) { $Stdin = 1; } else { @List = @ARGV; $Stdin = 0; } while ($file = &next_file() ) { &process($file); } exit 0; sub next_file { local($file) = ''; if ( $Stdin ) { chop($file = ); } else { if (@List) { $file = shift(@List); } } return $file; } sub process { local($file) = @_; if ( ! -f "$file" && ! -d "$file" ) { print STDOUT "$file: no such file or directory!\n"; return; } local($dev, $inode, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $file; local($now); $atime = scalar localtime($atime); $mtime = scalar localtime($mtime); $ctime = scalar localtime($ctime); $now = scalar localtime(time); $mode = sprintf("%o", $mode); if ( $Type ne '' ) { # print STDOUT "$file\[$Type\]: "; print STDOUT "$file: "; eval "print STDOUT \"\$${Type}\n\""; next; } print STDOUT <<"END"; $file: dev: $dev inode: $inode mode: $mode nlink: $nlink uid: $uid gid: $gid rdev: $rdev size: $size now: $now atime: $atime mtime: $mtime ctime: $ctime blksize: $blksize blocks: $blocks END }