Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: iterating through a hierarchy with a filter




On Apr 10, 2008, at 1:51 AM, Peter Stephenson wrote:
[...]

zsh doesn't have any specific code for descending hierarchies, so you
would have to do that by trickery.  If it's shallow enough that globbing
the whole thing in one go will work, you can do things along the lines
of (untested):

for file1 in source/**/*.xml; do
 file2=dest/${${file1##source/}:r}.txt
 destdir=${file2:h}
 [[ -d $destdir ]] || mkdir -p $destdir
 filter <$file1 >$file2
done

If that doesn't work even with a few small tweaks, you'll probably have
to tell us why before we can advise better.

Well, my hierarchy is a million small files.  So I doubt globbing will work -- should I try?  :)

Cheers,
Alexy


Messages sorted by: Reverse Date, Date, Thread, Author