adding a string ~300 times

Discussion in 'Perl Misc' started by gavino, Jul 28, 2006.

  1. gavino

    gavino Guest

    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"; ?
     
    gavino, Jul 28, 2006
    #1
    1. Advertising

  2. gavino

    Guest

    gavino <> wrote:
    > 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
     
    , Jul 28, 2006
    #2
    1. Advertising

  3. gavino

    gavino Guest

    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

    wrote:
    > gavino <> wrote:
    > > 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
     
    gavino, Jul 28, 2006
    #3
  4. gavino

    gavino Guest

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

    Michele Dondi wrote:
    > On 28 Jul 2006 13:29:58 -0700, "gavino" <> wrote:
    >
    > >how would a perler add that line below each instance of .bak"; ?

    >
    > perl -lpi -e '$_ .= "\nadded_line" if /\.bak";$/'
    >
    >
    > Michele
     
    gavino, Jul 28, 2006
    #4
  5. gavino

    Guest

    gavino <> wrote:

    Please don't top post.

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


    >> > 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 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
     
    , Jul 28, 2006
    #5
  6. gavino

    gavino Guest

    AWESOME
    this worked once I subbed in (my string) for (added_line)

    KICK ASS

    Michele Dondi wrote:
    > On 28 Jul 2006 13:29:58 -0700, "gavino" <> wrote:
    >
    > >how would a perler add that line below each instance of .bak"; ?

    >
    > perl -lpi -e '$_ .= "\nadded_line" if /\.bak";$/'
    >
    >
    > Michele
     
    gavino, Jul 29, 2006
    #6
  7. gavino

    gavino Guest

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

    wrote:
    > gavino <> wrote:
    >
    > Please don't top post.
    >
    > > :1,$s/\(internal.bak.*$\)/\1^V^M masters { 172.16.100.11; }; ^V^M

    >
    > >> > 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 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
     
    gavino, Jul 29, 2006
    #7
  8. gavino

    John Bokma Guest

    "gavino" <> wrote:

    > What is top post?


    Next time if you wonder about something in a technical group, don't do it
    aloud (might make you look silly), but enter it in Google, e.g.

    http://www.google.com/search?q=top post

    It works also very well for some errors or warnings you might get when
    using software.

    --
    John Bokma Freelance software developer
    &
    Experienced Perl programmer: http://castleamber.com/
     
    John Bokma, Jul 29, 2006
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JohnH.
    Replies:
    9
    Views:
    579
    R-D-C
    Apr 3, 2005
  2. Jarod

    asp.net 300 level ?

    Jarod, Nov 21, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    360
    Jarod
    Nov 21, 2005
  3. Ravi Ambros Wallau
    Replies:
    1
    Views:
    515
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 14, 2006
  4. Alex Vinokur
    Replies:
    4
    Views:
    317
    Matthew Schaefer
    Jan 30, 2005
  5. Replies:
    1
    Views:
    433
    Cowboy \(Gregory A. Beamer\)
    May 13, 2006
Loading...

Share This Page