Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Mar 1999 15:18:21 +0100 (MET)
From:      Reinhold Huber <Reinhold_Huber@Physik.TU-Muenchen.DE>
To:        freebsd-questions@freebsd.org
Subject:   Re: omething simple (sorry)
Message-ID:  <Pine.OSF.3.95.990307151644.26293A-100000@epsilon.cip.physik.tu-muenchen.de>

next in thread | raw e-mail | index | archive | help
Hello,

Ben Smithurst <ben@scientia.demon.co.uk> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.OSF.3.95.990307151644.26293A-100000>