Re: remove files sensibly
Arcady Genkin wrote:
> Hi all:
>
> How would I enter a command (or write a simple script) that would do:
>
> FOR EACH FILE *.elc IF THERE IS CORRESPONDING *.el, DELETE IT
Delete the .el?
I assume you have a backup (or the original .deb)...
Save this script as elcheck, `chmod +x elcheck` and run it.
-----
#!/usr/bin/perl
# elcheck --- Delete .el files for corresponding .elc files.
# Assuming we have archives of these el files.
# Peter Galbraith, Apr 27 1994 (My first perl script)
while (<*.elc>) {
chop; # Remove trailing "c" to get .el filename
if (-e $_) { # If this .el exists
print STDERR "Deleting $_\n"; # display its name
unlink || print "Can't delete $_\n" # and delete it!
}
}
-----
My perl scripts have since become more complicated!
--
Peter Galbraith, research scientist <GalbraithP@dfo-mpo.gc.ca>
Maurice Lamontagne Institute, Department of Fisheries and Oceans Canada
P.O. Box 1000, Mont-Joli Qc, G5H 3Z4 Canada. 418-775-0852 FAX: 775-0546
6623'rd GNU/Linux user at the Counter - http://counter.li.org/
Reply to: