Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Dec 2007 10:41:19 +0000
From:      "Frank Shute" <frank@esperance-linux.co.uk>
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:  <20071213104119.GA71105@melon.esperance-linux.co.uk>
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 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 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071213104119.GA71105>