Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.
As part of my holiday refactoring, I need to generate a list of directories containing XML docs. Surely there's something more natural than this?
find . -name '*.xml' | perl -nle '/(.*)\// && print $1' | uniq
I assumed there would be an option for find, but I didn't see it. (Well, gfind, that is. Solaris' find command is a pile o' junk, like so many other things on Solaris.)
I don't get it... (Score:1)
If you are using perl in that pipe, why not just use perl?
perl -MFile::Find -e 'find(sub { return unless /[.]xml$/; print "$File::Find::dir\n"}, @ARGV)' .
Best regards,
life is short
-printf (Score:1)
Gnu Find has a
-printfaction which you can use to emit just the names of the directories, like this:find -name '*.xml' -printf '%h\n' | uniq
I don't think it's possible to avoid the
uniqthough;-prunesounds promising, but isn't quite right to be useful here. So for a directory with lots of XML files in it, once it's found the first one and told you the directory you have to sit there and wait while it tells you again for all the others.Re: (Score:2)
Thanks! That's exactly what I was looking for.
Or the Unix equivalent: (Score:2)
Re: (Score:1)
Ovid is running this on a pretty big tree, so
-execisn’t a very good idea. Is this a Unix withoutxargs?Re: (Score:1)
Re: (Score:1)
Hm, good point. I guess
sedwould have to do in that case:Re: (Score:1)
Err, and the “
t; d;” part in the sed script isn’t even necessary.