adding a string ~300 times

G

gavino

I have a dns config file named.conf I need to reconfigure to enable a
slave dns server.

It involves making

zone "pims.teampcs.com" {
type slave;
file
"internal/pcs/master/pims.teampcs.com.zone.internal.bak";
};


look like

zone "pims.teampcs.com" {
type slave;
file
"internal/pcs/master/pims.teampcs.com.zone.internal.bak";
masters { 172.16.100.11; };
};

I don't know how to do this in vi since it involves adding a string on
a new line below each occourance of .bak";

how would a perler add that line below each instance of .bak"; ?
 
A

axel

gavino said:
I have a dns config file named.conf I need to reconfigure to enable a
slave dns server.

It involves making

zone "pims.teampcs.com" {
type slave;
file
"internal/pcs/master/pims.teampcs.com.zone.internal.bak";
};


look like

zone "pims.teampcs.com" {
type slave;
file
"internal/pcs/master/pims.teampcs.com.zone.internal.bak";
masters { 172.16.100.11; };
};

I don't know how to do this in vi since it involves adding a string on
a new line below each occourance of .bak";

:1,$s/\(internal.bak.*$\)/\1^V^M masters { 172.16.100.11; }; ^V^M
how would a perler add that line below each instance of .bak"; ?

Read in the file and after each line containing 'internal.bak add
the required additional line to the output.

Axel
 
G

gavino

How would I run that perl code if the file is called
named.conf.testing?
Is that a tab in the middle of the code?
also internal.bak is not unique, there is also external.bak so I guess
I change it to

:1,$s/\(internal.bak.*$\)/\1^V^M masters { 172.16.100.11; }; ^V^M
 
G

gavino

substitute added_line for the new line?
if the file to be changed is called named.conf.testing how would the
command look?
 
A

axel

Please don't top post.
:1,$s/\(internal.bak.*$\)/\1^V^M masters { 172.16.100.11; }; ^V^M
How would I run that perl code if the file is called
named.conf.testing?
Is that a tab in the middle of the code?
[snip]

That was a vi method of doing it :)

I left in spaces from your original example... not that they matter,
but did accidentally add a newline... not that that matters either.

Axel
 
G

gavino

What is top post?
I dont understand this response?
That should be run in vi?

Please don't top post.
:1,$s/\(internal.bak.*$\)/\1^V^M masters { 172.16.100.11; }; ^V^M
How would I run that perl code if the file is called
named.conf.testing?
Is that a tab in the middle of the code?
[snip]

That was a vi method of doing it :)

I left in spaces from your original example... not that they matter,
but did accidentally add a newline... not that that matters either.

Axel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top