From chrisb at jesmond.demon.co.uk Tue Aug 5 15:52:47 2003 From: chrisb at jesmond.demon.co.uk (Chris Benson) Date: Wed Aug 4 00:11:02 2004 Subject: /. book review: Learning Perl Objects, References & Modules Message-ID: <20030805215247.A6502@gamma.home> ... get a rave review on /. http://books.slashdot.org/books/03/08/01/0619259.shtml?tid=126&tid=145&tid=156&tid=188&tid=192 -- Chris Benson From chrisb at jesmond.demon.co.uk Thu Aug 21 09:20:26 2003 From: chrisb at jesmond.demon.co.uk (Chris Benson) Date: Wed Aug 4 00:11:02 2004 Subject: Woohoo! Message-ID: <20030821152026.A6486@gamma.home> User has a directory full of program files copied from MSWindows. Some files are UPPERCASE Some files are lowercase Some files are MixedCase How do we find the duplicates easily? And see which is newest? Tadah! perl -le 'print $_ , "\t", scalar localtime((stat)[9]) foreach sort {lc $a cmp lc $b} <*>' Sort all the filenames case-insensitively and print with last modified time. -- Chris Benson From chrisb at jesmond.demon.co.uk Thu Aug 21 11:54:00 2003 From: chrisb at jesmond.demon.co.uk (Chris Benson) Date: Wed Aug 4 00:11:02 2004 Subject: File-frigging, part II Message-ID: <20030821175400.A7006@gamma.home> So what we want to do is: - find files that only differ in CaSe - remove the oldest, keep the newest (the vendor who ships this cr*p doesn't know what the 'correct' case should be ... they intend to ship XXXXX.xxx in future: we'll see.) So:- #!/usr/bin/perl -wl # gather the evidence my %f; foreach my $file (<*>) { $f{lc $file}{$file} = (stat $file)[9]; # store the last-modified } foreach my $file (keys %f) { next if scalar keys %{ $f{$file} } == 1; # look for dups # find the newest my($new, @old) = sort { $f{$file}{$b} <=> $f{$file}{$a} } keys %{ $f{$file} }; # print an audit trail print "# keeping $new ", scalar localtime $f{$file}{$new}; print "rm $_\t# ", scalar localtime $f{$file}{$_} foreach @old; } -- Chris Benson From chrisb at jesmond.demon.co.uk Fri Aug 22 07:53:09 2003 From: chrisb at jesmond.demon.co.uk (Chris Benson) Date: Wed Aug 4 00:11:02 2004 Subject: [nick@ccl4.org: Re: File-frigging, part II] Message-ID: <20030822135309.A12118@gamma.home> ----- Forwarded message from Nicholas Clark ----- Subject: Re: File-frigging, part II On Thu, Aug 21, 2003 at 05:54:00PM +0100, Chris Benson wrote: > (the vendor who ships this cr*p doesn't know what the 'correct' case > should be ... they intend to ship XXXXX.xxx in future: we'll see.) http://hates-software.com/ has been provided for your ranting pleasure. Please feel free to wax lyrical there, if the killing urge gets to great. Nicholas Clark ----- End forwarded message ----- -- Chris Benson