From owner-freebsd-questions@FreeBSD.ORG Tue Dec 11 21:21:21 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 6F43116A476 for ; Tue, 11 Dec 2007 21:21:21 +0000 (UTC) (envelope-from elrap@web.de) Received: from fmmailgate03.web.de (fmmailgate03.web.de [217.72.192.234]) by mx1.freebsd.org (Postfix) with ESMTP id 2E4D413C442 for ; Tue, 11 Dec 2007 21:21:21 +0000 (UTC) (envelope-from elrap@web.de) Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate03.web.de (Postfix) with ESMTP id ADB54B7F5AF1; Tue, 11 Dec 2007 22:21:19 +0100 (CET) Received: from [84.152.163.151] (helo=freebsdangel.de) by smtp06.web.de with asmtp (WEB.DE 4.108 #208) id 1J2CXW-000892-00; Tue, 11 Dec 2007 22:21:18 +0100 Message-ID: <475EFF89.9040406@web.de> Date: Tue, 11 Dec 2007 22:22:17 +0100 From: Tino Engel User-Agent: Thunderbird 2.0.0.6 (X11/20071110) MIME-Version: 1.0 To: Halid Faith References: <002801c83c11$cd434e70$dc96eed5@ihlasnetym> <475EC318.90104@dial.pipex.com> <001001c83c33$669b46b0$dc96eed5@ihlasnetym> In-Reply-To: <001001c83c33$669b46b0$dc96eed5@ihlasnetym> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: elrap@web.de X-Sender: elrap@web.de X-Provags-ID: V01U2FsdGVkX1+cABh3yXQ/IikMfXczV+o/ebPqhiJbaN1uO59e AQ8WqnNPjPUd1xCsNgvED8Ncp+YjE4nkwEtYCqenQL1Qc+fNsb 2XKyThoMQ= Cc: freebsd-questions@freebsd.org 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 21:21:21 -0000 Halid Faith schrieb: > Ok > But I have another problem, > I couldn't use any command interior of sed command. That's to say I have a > script; > > yy="file5" > for i in `cat file1`; > do > sed -e 's/old1/new1\ \'$i'/g' -e 's/old2/'cut -d, -f 1 ${yy}'/g' file2 > > file3 > done > > When I run the script, I get an error, due to using cut command > > > > For using environment variables in sed, you have to use # instead of / VAR="TEXT" sed s#OLD#${VAR}#g file1 Will replace OLD by TEXT. Do not use quotations here... Rg, Tino