From owner-freebsd-questions Thu Nov 21 11:48:52 2002 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 4226837B401 for ; Thu, 21 Nov 2002 11:48:50 -0800 (PST) Received: from beck.quonix.net (beck.quonix.net [64.239.136.146]) by mx1.FreeBSD.org (Postfix) with ESMTP id BD1A743E6E for ; Thu, 21 Nov 2002 11:48:49 -0800 (PST) (envelope-from john@essenz.com) Received: from localhost (pcp01324074pcs.neave01.pa.comcast.net [68.81.22.158]) by beck.quonix.net (8.11.6/8.11.6) with ESMTP id gALJkRA89764; Thu, 21 Nov 2002 11:46:27 -0800 (PST) (envelope-from john@essenz.com) Date: Thu, 21 Nov 2002 14:48:42 -0500 Subject: Re: please help: how do I replace words Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v482) Cc: freebsd-questions@FreeBSD.ORG To: adrian kok From: John Von Essen In-Reply-To: <20021121192354.42378.qmail@web21207.mail.yahoo.com> Message-Id: <3CF8F292-FD8A-11D6-8DAD-0003933DDCFA@essenz.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.482) Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Use the following with the -e option, not the -n option: sed -e 's/192.168.0.1/172.16.0.1/g' in-file > out-file With in-file containing: abc.com 192.168.0.1 localhost.abc.com 127.0.0.1 And resulting out-file containing: abc.com 172.16.0.1 localhost.abc.com 127.0.0.1 -John Von Essen On Thursday, November 21, 2002, at 02:23 PM, adrian kok wrote: > Hi all > > I have problem to replace words > from 192.168.0.1 to 172.16.0.1 in file abc.com > > file content: > abc.com 192.168.0.1 > localhost.abc.com 127.0.0.1 > > I tried: > > sed -n 's/192.168.0.1/172.16.0.1/w abc.com.tmp' > abc.com > > file abc.com.tmp > only shows l line > abc.com 172.16.0.1 > and missing localhost.abc.com 127.0.0.1 > > > > I tried and it is same! > sed -n 's/192.168.0.1/172.16.0.1/gw abc.com.tmp' > abc.com > > I can't use perl because the sed is within shell > script > > TIA > > > > > > > > > > > > > > > > _______________________________________________________________________ > Do You Yahoo!? > Get your free @yahoo.com.hk address at http://mail.english.yahoo.com.hk > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message > > > Do: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message