From owner-freebsd-questions@FreeBSD.ORG Wed Sep 3 20:10:20 2003 Return-Path: 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 4811816A4C1 for ; Wed, 3 Sep 2003 20:10:20 -0700 (PDT) Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3495643FE9 for ; Wed, 3 Sep 2003 20:10:19 -0700 (PDT) (envelope-from ler@lerctr.org) Received: from lerlaptop.lerctr.org (lerlaptop.lerctr.org [207.158.72.14]) (authenticated bits=0)h843AEGK003117; Wed, 3 Sep 2003 22:10:15 -0500 (CDT) Date: Wed, 03 Sep 2003 22:10:14 -0500 From: Larry Rosenman To: Mike Hogsett Message-ID: <158370000.1062645014@lerlaptop.lerctr.org> In-Reply-To: <200309040238.h842cKFv021907@quarter.csl.sri.com> References: <200309040238.h842cKFv021907@quarter.csl.sri.com> X-Mailer: Mulberry/3.1.0b6 (Linux/x86) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: by amavisd-milter (http://amavis.org/) cc: freebsd-questions@freebsd.org Subject: Re: How do I change the extensions on a slew of files X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Sep 2003 03:10:20 -0000 --On Wednesday, September 03, 2003 19:38:20 -0700 Mike Hogsett wrote: > >> from an sh type shell >> for i in *.inc >> do >> z=`echo $i | sed -e "s/inc/htm/g"` >> mv ${i} ${z} >> done > > This won't give expected results for a file named "fooinc.inc". It will > become "foohtm.htm". I realize that based on the file names given in the > original email this doesn't appear to be an issue, but changing the sed > command to > > sed -e 's/\.inc$/\.html/' > > may give better (more generally useful) results. Also note the ' instead > of " so that the shell doesn't perform variable expansion within the sed > command text. The shell will ignore the $ and instead sed uses it to match > end of line or string in this case. > > - Mike thanks, Mike. What you bring up, is of course, valid. -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749