It’s been quite a while since I’ve had such a quite and generally relaxing weekend as this one has been. The benefit this has brought is that it’s given me a chance to catch up on various projects and put in a bit of research time for my uni project next year (which incidentally starts at the beginning of October).
Although we were given a brief introductory course to Perl last year I’ve decided to try and learn a bit more as it looks like a pretty useful language to know to a decent level of expertise. With this in mind I’ve obtained the book “Programming Perl” from the excellent O’Reilly series of computer books.
It’s a pretty thick book so it’ll take a while to condense but it looks like it’s well written and the examples are clear to follow so I don’t think it’ll be a problem. To get started I’ve written a useful little script for deleting those pesky folder settings files (.DS_Store etc) which various OS’s create when you browse any folder which is writable:
#!/usr/bin/perl -w
open ARGV, “find ./ -follow -name .DS_Store ;
find ./ -follow -name ._* ;
find ./ -follow -name .Trash-* |”
|| die “Problem opening pipe, reason $!n”;while(<>) {
print “Deleting: $_”;
chomp;
$sort =$_;
`rm -rf “$sort”`;
}>
Basically just recurses through every folder below the one its executed from and deletes any of the files its finds which match the command. To use it simply copy the code into a text file (cleanup.pl) and make it executable (chmod u+x cleanup.pl). If you modify the code be very careful because if you get the ‘find’ command wrong you could end up deleting a lot you don’t mean to!
Reply