Skip site navigation (1)Skip section navigation (2)
Date:      11 Sep 1998 01:55:17 +0200
From:      dag-erli@ifi.uio.no (Dag-Erling =?iso-8859-1?Q?Co=EFdan?=  =?iso-8859-1?Q?Sm=F8rgrav?= )
To:        Greg Lehey <grog@lemis.com>
Cc:        Wes Peters <wes@softweyr.com>, "Jordan K. Hubbard" <jkh@time.cdrom.com>, freebsd-chat@FreeBSD.ORG
Subject:   Re: ed
Message-ID:  <xzp67evfrq2.fsf@hrotti.ifi.uio.no>
In-Reply-To: Greg Lehey's message of "Fri, 11 Sep 1998 08:51:19 %2B0930"
References:  <9698.905291210@time.cdrom.com> <35F7CF17.E0C82BCA@softweyr.com> <19980911085119.L583@freebie.lemis.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Greg Lehey <grog@lemis.com> writes:
> So what's wrong with
> 
> for file in `find . \( -name '*.[ch] -o -name Makefile \) -print`  
> do
> sed <file >file.new 's/Good Time Engineering/Mega Baby Bell/g'
> if [ $? -eq 0 ]; then
>   mv file.new
> fi
> echo $file edited.
> done

Well, you forgot a few ' and $ here and there, it will barf at the
first mv for want of a second argument, and it can be written more
concisely (and more readably):

for f in `find . \( -name '*.[ch]' -o -name Makefile \)` ; do
  sed 's/Good Time Engineering/Mega Baby Bell/g' "${f}" >"${f}.new" &&
    mv "${f}.new" "${f}" && echo "edited ${f}"
done

Apart from that, nothing :)

DES
-- 
Dag-Erling Smørgrav - dag-erli@ifi.uio.no

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzp67evfrq2.fsf>