From owner-freebsd-questions@FreeBSD.ORG Sun Oct 16 17:50:21 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 89FF916A42C for ; Sun, 16 Oct 2005 17:50:21 +0000 (GMT) (envelope-from drew@mykitchentable.net) Received: from relay04.roc.ny.frontiernet.net (relay04.roc.ny.frontiernet.net [66.133.182.167]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0572243D5A for ; Sun, 16 Oct 2005 17:50:20 +0000 (GMT) (envelope-from drew@mykitchentable.net) Received: from filter07.roc.ny.frontiernet.net (filter07.roc.ny.frontiernet.net [66.133.183.74]) by relay04.roc.ny.frontiernet.net (Postfix) with ESMTP id 512F13582F3; Sun, 16 Oct 2005 17:50:20 +0000 (UTC) Received: from relay04.roc.ny.frontiernet.net ([66.133.182.167]) by filter07.roc.ny.frontiernet.net (filter07.roc.ny.frontiernet.net [66.133.183.74]) (amavisd-new, port 10024) with LMTP id 21643-07-31; Sun, 16 Oct 2005 17:50:20 +0000 (UTC) Received: from blacklamb.mykitchentable.net (67-51-164-214.dsl1.elk.ca.frontiernet.net [67.51.164.214]) by relay04.roc.ny.frontiernet.net (Postfix) with ESMTP id 0205F358329; Sun, 16 Oct 2005 17:50:08 +0000 (UTC) Received: from [192.168.1.3] (unknown [192.168.1.3]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by blacklamb.mykitchentable.net (Postfix) with ESMTP id 743D0153F0F; Sun, 16 Oct 2005 10:50:05 -0700 (PDT) Message-ID: <435292CC.1080008@mykitchentable.net> Date: Sun, 16 Oct 2005 10:50:04 -0700 From: Drew Tomlinson User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: f-q References: <435027A3.8000908@mykitchentable.net> <35c231bf0510141524u133f2d1bkeb46d60e112ee413@mail.gmail.com> <435189CD.8080606@mykitchentable.net> <20051016063306.GB2152@holestein.holy.cow> In-Reply-To: <20051016063306.GB2152@holestein.holy.cow> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-2.3.2 (20050629) at filter07.roc.ny.frontiernet.net Cc: David Kirchner Subject: Re: Help Understanding While Loop X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Oct 2005 17:50:21 -0000 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