Date: Sun, 16 Oct 2005 10:50:04 -0700 From: Drew Tomlinson <drew@mykitchentable.net> To: f-q <freebsd-questions@freebsd.org> Cc: David Kirchner <dpk@dpk.net> Subject: Re: Help Understanding While Loop Message-ID: <435292CC.1080008@mykitchentable.net> In-Reply-To: <20051016063306.GB2152@holestein.holy.cow> References: <435027A3.8000908@mykitchentable.net> <35c231bf0510141524u133f2d1bkeb46d60e112ee413@mail.gmail.com> <435189CD.8080606@mykitchentable.net> <20051016063306.GB2152@holestein.holy.cow>
next in thread | previous in thread | raw e-mail | index | archive | help
On 10/15/2005 11:33 PM Parv wrote: >in message <435189CD.8080606@mykitchentable.net>, >wrote Drew Tomlinson thusly... > > >>Thus I set the following variables: >> >>remote_pictures_dir="/multimedia/Pictures" >>local_pictures_dir="/tv/pictures" >>find_args="-iname '*.jpg' -or -iname '*.gif'" >> >>Then I called the 'find' command as follows: >> >>for original in $(/usr/bin/find $remote_pictures_dir $find_args -print) >> >>But when I run my script, I get "/usr/bin/find: invalid predicate >>`-iname '*.jpg' -or -iname '*.gif''". >> >> > >I don't get the "invalid predicate"; i get nothing printed at all >(bash3 & sh). > > > > >>However if I don't try and >>use $find_args and type the arguments in specifically, the script >>runs fine. >> >> > >Are you really sure about the "runs fine" part? Here, when the >"-iname" options were not surrounded by '\(' & '\)', find searched >only for the last option, in this case "-iname '*.gif'", ignoring >all the '*.jpg' files. > > I thought I was but then after continuing to play around with it I noticed the phenomena you describe above. That's when I added the '\(' as you mention. Good catch! >>I tried various combinations of quoting and escaping >>those quotes but can't come up with a combination that works. >> >> > >Add "eval" before "find" so that find recognizes $find_args as >separate options not one long string, and group $find_args to make >it work what you actually wanted ... > > for f in $( eval "find $dir \( $find_args \) -print" ) > do > echo "$f" > done > > Thank you very much!!! This works great. Drew -- Visit The Alchemist's Warehouse Magic Tricks, DVDs, Videos, Books, & More! http://www.alchemistswarehouse.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?435292CC.1080008>