Date: Thu, 13 Dec 2007 16:33:27 +0200 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Halid Faith <maslak@ihlas.net.tr> Cc: freebsd-questions@freebsd.org Subject: Re: How to use cut or awk commands into sed command ? Message-ID: <20071213143327.GB1937@kobe.laptop> In-Reply-To: <01bc01c83d5a$bcd907b0$dc96eed5@ihlasnetym> References: <015f01c83d04$a1df2b20$dc96eed5@ihlasnetym> <20071213011248.GA2602@kobe.laptop> <01bc01c83d5a$bcd907b0$dc96eed5@ihlasnetym>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2007-12-13 09:35, Halid Faith <maslak@ihlas.net.tr> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071213143327.GB1937>