From owner-freebsd-questions@FreeBSD.ORG Tue Jul 15 19:02:30 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 01A6F106566C for ; Tue, 15 Jul 2008 19:02:30 +0000 (UTC) (envelope-from dkelly@Grumpy.DynDNS.org) Received: from smtp.knology.net (smtp.knology.net [24.214.63.101]) by mx1.freebsd.org (Postfix) with ESMTP id 85B688FC12 for ; Tue, 15 Jul 2008 19:02:29 +0000 (UTC) (envelope-from dkelly@Grumpy.DynDNS.org) Received: (qmail 29660 invoked by uid 0); 15 Jul 2008 19:02:28 -0000 Received: from unknown (HELO Grumpy.DynDNS.org) (216.186.148.249) by smtp5.knology.net with SMTP; 15 Jul 2008 19:02:28 -0000 Received: by Grumpy.DynDNS.org (Postfix, from userid 928) id CAD4328429; Tue, 15 Jul 2008 14:02:24 -0500 (CDT) Date: Tue, 15 Jul 2008 14:02:24 -0500 From: David Kelly To: Gary Kline Message-ID: <20080715190224.GC21840@Grumpy.DynDNS.org> References: <20080714201241.GA22443@thought.org> <20080715073651.P1638@wojtek.tensor.gdynia.pl> <20080715183500.GA76088@thought.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080715183500.GA76088@thought.org> User-Agent: Mutt/1.4.2.3i Cc: Wojciech Puchar , FreeBSD Mailing List Subject: Re: why is this script failing? 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: Tue, 15 Jul 2008 19:02:30 -0000 On Tue, Jul 15, 2008 at 11:35:00AM -0700, Gary Kline wrote: > On Tue, Jul 15, 2008 at 07:37:02AM +0200, Wojciech Puchar wrote: > > > > > > why is this script not finding them? > > > > > > > > >wav=/tmp/kde-kline/\*wav\* > > > > why you put \ before * > > to allow the shell to catch various formsof strings with "wav" > embedded. I questioned that escape earlier. Without the \ escape the variable ${wav} will contain all the files matching the pattern. But with the escape it will literally be "/tmp/kde-kline/*wav*". Wildcard expansion doesn't occur until later when Gary does something like this: rm ${wav} which is processed as if he had just now typed: rm /tmp/kde-kline/*wav* while without the escape it might appear like this: rm /tmp/kde-kline/file1.wav /tmp/kde-kline/file2.wav Is probably best to postpone wildcard expansion until the last moment because if any of the filenames contain spaces the space will probably cause a break between arguments. The first time the wildcard expands to a filename with a space the space will be escaped. But the second time you use it that escape is lost. So its best to expand it in the place its needed. -- David Kelly N4HHE, dkelly@HiWAAY.net ======================================================================== Whom computers would destroy, they must first drive mad.