Oliver Fromme check+jw8aa100rsueqp0r at
Thu Feb 14 05:06:38 PST 2008

Simon 'corecode' Schubert wrote:
 > Rahul Siddharthan wrote:
 > > For example, how do you use "find" to find all files in a directory
 > > that end in ".el" and don't have a corresponding ".elc" file?  
 > > Answer:
 > >  find . -name '*.el' -print  \
 > >     |sed 's/^/FOO=/' \
 > >     |sed 's/$/; if [ ! -f ${FOO}c ]; then echo $FOO; fi/'  \
 > >     | sh

There are dozens of ways to do it.  The above answer is
certainly not the best one.  Except if the intention is
to demonstrate how difficult it is.  :-)

 > I'd go for (if only in the current directory, not subdirs)
 > for f in *.el
 > do
 >        [ -f "${f}c" ] || echo "$f"
 > done

That's much better.  I would do it this way (doesn't
require any shell loops, so it's more efficient):

ls *.el *.elc | sed 's/c$//' | uniq -c | awk '$1==2{print $2}'

I don't think anyone has so many .el files that it
will overflow argmax, so I simply used ls.  Otherwise
"echo *.el *.elc | tr ' ' '\n' | ..." instead will do
for any number of files.

With zsh's extended globbing, the problem can be
solved thusly:

echo *.el(e:'[ -f ${REPLY}c ]':)

And to include subdirectories recursively, only a
simple modification is required:

echo **/*.el(e:'[ -f ${REPLY}c ]':)

Best regards

Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:

More information about the Kernel mailing list