From owner-freebsd-questions@FreeBSD.ORG Tue Dec 11 22:26:20 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9EF1016A417 for ; Tue, 11 Dec 2007 22:26:20 +0000 (UTC) (envelope-from danny@ricin.com) Received: from smtpq1.tilbu1.nb.home.nl (smtpq1.tilbu1.nb.home.nl [213.51.146.200]) by mx1.freebsd.org (Postfix) with ESMTP id 6AD2F13C474 for ; Tue, 11 Dec 2007 22:26:20 +0000 (UTC) (envelope-from danny@ricin.com) Received: from [213.51.146.188] (port=53019 helo=smtp3.tilbu1.nb.home.nl) by smtpq1.tilbu1.nb.home.nl with esmtp (Exim 4.60) (envelope-from ) id 1J28Te-0006mh-SY for freebsd-questions@freebsd.org; Tue, 11 Dec 2007 18:01:03 +0100 Received: from cp1228410-a.dbsch1.nb.home.nl ([84.27.157.163]:55266 helo=desktop.homenet) by smtp3.tilbu1.nb.home.nl with smtp (Exim 4.60) (envelope-from ) id 1J28Te-0003Bv-5M for freebsd-questions@freebsd.org; Tue, 11 Dec 2007 18:01:02 +0100 Received: by desktop.homenet (sSMTP sendmail emulation); Tue, 11 Dec 2007 18:00:19 +0100 From: "Danny Pansters" To: freebsd-questions@freebsd.org Date: Tue, 11 Dec 2007 18:00:19 +0100 User-Agent: KMail/1.9.7 References: <002801c83c11$cd434e70$dc96eed5@ihlasnetym> In-Reply-To: <002801c83c11$cd434e70$dc96eed5@ihlasnetym> X-Face: (Zs+'ncTcchkOX|~t6{?Iii=O!G#WEK!+OD0|-F=i%1pvP5V_Sz4PaJC8o)=?utf-8?q?MiSnH/JMJFy=0A=09oBN-My?=, v":S7, (=?utf-8?q?mmkPm=27U=7BMgT+eM=2EBd=5Cp/P!dr=5DhOTXqpse21O!=25Ct=60SE=2EOodq?= =?utf-8?q?=5Dry=5E=23kU=5E=0A=09-?=GT.[8D}i$6P>=" =?utf-8?q?=23=0A=09*J+4d=7E?= MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200712111800.19674.danny@ricin.com> X-Spam-Score: 0.0 (/) Subject: Re: How to replace two strings in a file in the same time with sed command ? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Dec 2007 22:26:20 -0000 On Tuesday 11 December 2007 17:20:50 Halid Faith wrote: > I want to replace two or more strings in a file in the same time with sed > command. How do I that ? > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" just use -e s/foo/bar/ as many times as needed. e.g. %cat afile foo1 foo3 foo2 foo7 %sed -e s/foo1/bar1/ -e s/foo2/bar2/ -e s/foo3/bar3/ -i .bak afile %cat afile.bak foo1 foo3 foo2 foo7 %cat afile bar1 bar3 bar2 foo7 Dan