DragonFly kernel List (threaded) for 2008-02
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Re: Globbing
Michael Neumann 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
>
> Hm, why don't you use a "real" language, instead of hacking shell
> scripts. I understand that they are useful in some cases, as /bin/sh is
> cross-platform and installed by default. For anything else, take perl,
> python or ruby.
I think the point was to provide a portable solution that
would work with the basic tools on any UNIX box. I agree,
in such cases it makes sense to us an advanced language.
(On the other hand, zsh is pretty advanced, too. ;-)
> In Ruby this becomes the following:
>
> Dir['**/*.el'].reject {|f| File.exist?(f + "c")}.each {|f| puts f}
>
> And that's just a simple example. Once it gets more complex, the
> power of more advanced scripting languages pay off a lot more.
This would be the Python way to do it, just for the record:
[x for x in listdir(".") if exists(x + "c")]
Best regards
Oliver
--
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: http://www.secnetix.de/bsd
- Follow-Ups:
- Re: Globbing
- From: Oliver Fromme <check+jw8m7u00rsbgw1jh@fromme.com>
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]