[Discuss] cygwin problem
Noel Burton-Krahn
noel at burton-krahn.com
Wed Apr 16 13:24:00 PDT 2008
There are a couple of traps here:
for FIL in `find -iname '$DOC_TYPE'`; do
1. the single-quotes around '$DOC_TYPE' will prevent it from expanding
2. this causes bash to buffer the whole output of find, then split it.
The pipe below will work for huge directory listings
I'd try this instead:
find "$DIR" -iname "$DOC_TYPE" | while read FIL; do
~Noel
On Wed, Apr 16, 2008 at 11:41 AM, pw <p.willis at telus.net> wrote:
> Hello Noel,
>
>
>
> The original script is slightly more complex.
>
> IFS=$'\n'
>
> export BACKUP_DIR=/cygdrive/some_dir/
>
> #where drives.txt is a list of lower case drive letters
>
> for DRIVE in `cat /cygdrive/c/backup/drives.txt`;do
> cd /cygdrive/$DRIVE
>
> #where doc_types is a list of file specs ie: '*.doc'
>
> for DOC_TYPE in `cat /cygdrive/c/backup/doc_types.txt`; do
> for FIL in `find -iname '$DOC_TYPE'`; do
> #cp -dpR "$FIL" "$BACKUP_DIR"
> echo $FIL;
> done
> done
> done
>
> I haven't tried putting the full path into the find command though.
>
> ie:
>
> for FIL in `find /cygdrive/$DRIVE -iname '$DOC_TYPE'`; do
>
> I'll try that.........Nope, no change.
>
> The same script works fine in a linux box.
> I'm thinking bash is broken on cygwin or it's overflowing memory
> or something.
>
> Peter
>
>
> Noel Burton-Krahn wrote:
>
> > what does this produce?
> >
> > find . -iname '*.doc'
> >
> > Note the ".". Your example didn't have a directory name before the iname
> >
> > ~Noel
> >
> >
> > On Wed, Apr 16, 2008 at 11:09 AM, pw <p.willis at telus.net> wrote:
> >
> > > Hello,
> > >
> > > I have been trying to get a small bash script to work in
> > > cygwin but am having some problems.
> > >
> > > If I use a find command in a loop on the command line
> > > it works fine:
> > >
> > > ie:
> > >
> > > /> for FIL in `find -iname '*.doc'`; do echo $FIL; done
> > >
> > > (comes up with loads of files)
> > >
> > >
> > > If I put the same loop in a bash script:
> > >
> > > ie:
> > >
> > > for FIL in `find -iname '*.doc'`; do
> > > echo $FIL
> > > done
> > >
> > > and then run 'sh script.sh' to test, find doesnt come up with any
> > > files...(!?)
> > >
> > > Any ideas anyone?
> > >
> > > Peter
> > > _______________________________________________
> > > Discuss mailing list
> > > Discuss at vlug.org
> > > http://ladybug.vlug.org/cgi-bin/mailman/listinfo/discuss
> > >
> > >
> > _______________________________________________
> > Discuss mailing list
> > Discuss at vlug.org
> > http://ladybug.vlug.org/cgi-bin/mailman/listinfo/discuss
> >
> >
>
>
> _______________________________________________
> Discuss mailing list
> Discuss at vlug.org
> http://ladybug.vlug.org/cgi-bin/mailman/listinfo/discuss
>
More information about the Discuss
mailing list