#! /usr/bin/perl use strict; use warnings; use File::Find(); use Getopt::Long(); use Cwd(); sub help { print <<_HELP_; Usage: $0 [--root root_directory] This program prints out file details for all files relative to the supplied root directory or the current working directory _HELP_ } MAIN: { my ($root) = Cwd::cwd(); my ($help); Getopt::Long::GetOptions('help', \$help, 'root', \$root); if ($help) { help(); exit(0); } $root =~ s/\/\s*$//; # strip any trailing /'s off the root path0 File::Find::find({ 'no_chdir' => 1, 'wanted' => sub { if ($File::Find::name =~ /^(.*)$/) { # you can use this regular expression to strip out file names with illegal chars if desired my ($full_path) = ($1); my ($chrooted_path) = $full_path; $chrooted_path =~ s/^$root//; # strip the root path off my ($uid, $size, $mtime) = ((stat($full_path))[4,7,9]); my ($uname) = (getpwuid($>))[0]; print "$uname,$size," . localtime($mtime) . ",$chrooted_path\n"; } else { print STDERR "Skipped $File::Find::name\n"; } }}, $root); }