From owner-freebsd-questions Sun Mar 7 6:19:29 1999 Delivered-To: freebsd-questions@freebsd.org Received: from srv.cip.physik.tu-muenchen.de (srv.cip.physik.tu-muenchen.de [129.187.41.1]) by hub.freebsd.org (Postfix) with ESMTP id F254E14CA3 for ; Sun, 7 Mar 1999 06:18:40 -0800 (PST) (envelope-from Reinhold_Huber@Physik.TU-Muenchen.DE) Received: from epsilon.cip.physik.tu-muenchen.de (epsilon.cip.physik.tu-muenchen.de [129.187.184.90]) by srv.cip.physik.tu-muenchen.de (8.9.1/8.9.1) with ESMTP id PAA02182 for ; Sun, 7 Mar 1999 15:18:22 +0100 (MET) Received: from localhost (rhuber@localhost) by epsilon.cip.physik.tu-muenchen.de (8.8.6/8.8.6) with SMTP id PAA26974 for ; Sun, 7 Mar 1999 15:18:21 +0100 (MET) X-Authentication-Warning: epsilon.cip.physik.tu-muenchen.de: rhuber owned process doing -bs Date: Sun, 7 Mar 1999 15:18:21 +0100 (MET) From: Reinhold Huber To: freebsd-questions@freebsd.org Subject: Re: omething simple (sorry) Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hello, Ben Smithurst wrote: > James Kalmadge wrote: >> for file in *.txt >> do >> cp $file `echo $file | awk -F. '{print $1}'`.old >> done > That won't work if the file name has a dot before the .txt, part.1.txt > and part.2.txt for example. For this reason, I'd suggest: for file in *.txt do cp $file `echo $file |sed -e 's/.txt$/.old/'` done This should replace any .txt ending without replacing embedded .txt's in the filename (with the $ in the regexp). Greetings, Reinhold Huber To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message