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

Re: iterating through a hierarchy with a filter



On Thu, Apr 10, 2008 at 02:03:21AM -0700, Alexy Khrabrov wrote:
> 
> On Apr 10, 2008, at 1:51 AM, Peter Stephenson wrote:

[...]

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

[...]

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

Doing it as a stream should work, e.g.:

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

-- 
Thor



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