From owner-freebsd-questions@FreeBSD.ORG Thu Dec 13 10:41:30 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 49FB616A468 for ; Thu, 13 Dec 2007 10:41:30 +0000 (UTC) (envelope-from frank@esperance-linux.co.uk) Received: from mailout.zetnet.co.uk (mailout.zetnet.co.uk [194.247.47.231]) by mx1.freebsd.org (Postfix) with ESMTP id 0AEE813C458 for ; Thu, 13 Dec 2007 10:41:29 +0000 (UTC) (envelope-from frank@esperance-linux.co.uk) Received: from irwell.zetnet.co.uk ([194.247.47.48] helo=zetnet.co.uk) by mailout.zetnet.co.uk with esmtp (Exim 4.50) id 1J2lVN-00080T-A3 for freebsd-questions@freebsd.org; Thu, 13 Dec 2007 10:41:25 +0000 Received: from esperance.zetnet.co.uk (54-144.adsl.zetnet.co.uk [194.247.54.144]) by zetnet.co.uk (8.14.1/8.14.1/Debian-9) with SMTP id lBDAfOS5027860 for ; Thu, 13 Dec 2007 10:41:24 GMT Received: (qmail 71115 invoked by uid 1001); 13 Dec 2007 10:41:19 -0000 From: "Frank Shute" Date: Thu, 13 Dec 2007 10:41:19 +0000 To: Halid Faith Message-ID: <20071213104119.GA71105@melon.esperance-linux.co.uk> References: <015f01c83d04$a1df2b20$dc96eed5@ihlasnetym> <20071213011248.GA2602@kobe.laptop> <01bc01c83d5a$bcd907b0$dc96eed5@ihlasnetym> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01bc01c83d5a$bcd907b0$dc96eed5@ihlasnetym> User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD 6.3-RC1 i386 X-Organisation: 'Esperance Linux' X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (zetnet.co.uk [194.247.46.1]); Thu, 13 Dec 2007 10:41:25 +0000 (GMT) Cc: freebsd-questions@freebsd.org Subject: Re: How to use cut or awk commands into sed command ? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Frank Shute List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Dec 2007 10:41:30 -0000 On Thu, Dec 13, 2007 at 09:35:29AM +0200, Halid Faith wrote: > > Let me try to explain > I have a file called A which contains variable values as below; > file1, abc12 > foot1, cba11 > boby, def123 > ... > > Also I have another file called B which contains partly valuable values as > following; > ### file of A begin > Server valuable1 > Client valuable2 > #### the file end > > I have to assign the first column valuables in A to valuable1 in B and > assign second column valuable1 in A to valuable2 in B. > Finally I should see as following in a file called C > Server file1 > Client abc12 > > Server foot1 > Client cba11 > > Server boby > Client def123 > > How can I do that ? Could you give me a script ? > > Also does it possible to define two or more variable in for loop as below > for i in `cat file1` a in `cat file2` ; > do > sed -e "s/oldstring1/$i/" -e "s/oldstring2/$a/" > done > > Thanks Have a look at join(1). You should be able to knock something together with join and sed. Personally, I'd use perl for something like this. (Not much help if you don't know perl). -- Frank Contact info: http://www.esperance-linux.co.uk/misc/contact.html