#!/usr/bin/perl -w # (C) 2003-2007 Willem Jan Hengeveld # Web: http://www.xs4all.nl/~itsme/ # http://wiki.xda-developers.com/ # # $Id: which 1502 2007-04-15 07:54:20Z itsme $ # use strict; # searches entire path for specified files, files may be specified with wildcards. use POSIX; #use Time::local; use Getopt::Long; my $verbose= 0; GetOptions("verbose" => \$verbose); my @found; my $splitchar= $ENV{PATH}=~/;/ ? ";" : ":"; for my $dir (split $splitchar, $ENV{PATH}) { $dir =~ s/\\/\//g; $dir =~ s/\/$//g; $dir =~ s/([ ])/\\$1/g; for my $pattern (@ARGV) { print "searching $dir for $pattern\n" if ($verbose); for my $file (glob("$dir/$pattern")) { if (-e $file) { push(@found, $file); } } } } print map { sprintf("%9d %s %s\n", -s $_, POSIX::strftime("%Y-%m-%d %H:%M:%S", localtime getmtime($_)), $_); } @found; sub getmtime { my $filename= shift; my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat $filename; return $mtime; }