[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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
> 

You could use something like:

  find . -name '*.elc' -print | sed -e s/\.elc/\.el/ | xargs rm -f
  ___________________________   ____________________   _____ _____  
   |                             |                      |     |
   +- find the *.elc files       +- .elc -> .el         |     +- delete
                                                        |
                                                        +- collect on
                                                           to one line

Note that this won't work on a file like "foo.elc.elc" -- you want
to delete "foo.elc.el" probably, but this would try to delete
"foo.el.el" instead...

>
> Are there any good online resources about writing similar scripts?
> 

Not that I know of... but the man pages are good!  Hardest part is
finding out what commands you need to know.

Or take a look at perl.  Lots of resources on that!  And it is
perfect for this sort of thing.

Kirk


Reply to: