From owner-freebsd-questions@FreeBSD.ORG Thu Dec 13 14:34:07 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 AE51F16A41A for ; Thu, 13 Dec 2007 14:34:07 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id 1991C13C448 for ; Thu, 13 Dec 2007 14:34:06 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (vader.bytemobile-rio.ondsl.gr [83.235.57.37]) (authenticated bits=128) by igloo.linux.gr (8.14.1/8.14.1/Debian-9) with ESMTP id lBDEXYb4010623 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 13 Dec 2007 16:33:51 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.2/8.14.2) with ESMTP id lBDEXS9x002154; Thu, 13 Dec 2007 16:33:28 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.2/8.14.2/Submit) id lBDEXRoh002153; Thu, 13 Dec 2007 16:33:27 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Thu, 13 Dec 2007 16:33:27 +0200 From: Giorgos Keramidas To: Halid Faith Message-ID: <20071213143327.GB1937@kobe.laptop> 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> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-4.003, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.40, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No 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 List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Dec 2007 14:34:07 -0000 On 2007-12-13 09:35, 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 ? Look carefully at the second input file: Server valuable1 Client valuable2 Now look *very* carefully at the output you want: Server file1 Client abc12 Server foot1 Client cba11 Server boby Client def123 Can you imagine a *loop* which reads the input file and creates the second? In `pseudo-code' this would be something like: for each pair of (server, client) from `file1': for each line in `file2': substitute `server' and `client' in `line' print resulting line print an empty line That shouldn't be *too* hard to write in a shell script. Now that you have the outline, see if you have better luck. - Giorgos