How to use cut or awk commands into sed command ?
keramida at ceid.upatras.gr
Thu Dec 13 06:34:07 PST 2007
On 2007-12-13 09:35, Halid Faith <maslak at 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
> ### 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:
Now look *very* carefully at the output you want:
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.
More information about the freebsd-questions