Inserting records in bash script [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite













This question already has an answer here:



  • Inserting A records in dns zone [closed]

    2 answers



Any feedback will be appreciated.



I would like to insert the IP address, however the script is inserting the domain name instead of IP.



File name: file.txt



dns50.com: 1.1.1.1
dns51.com: 2.2.2.2
dns52.com: 3.3.3.3


Script:



for x in `cat /root/file.txt | cut -d: -f1` ; do 
echo "ns1 14400 IN A $x" >> /var/named/$x.db
done


Inserted data when running the about script.



file: /var/named/dns50.com.db



ns1 14400 IN A dns50.com


file: /var/named/dns51.com.db



ns1 14400 IN A dns51.com


file: /var/named/dns52.com.db



ns1 14400 IN A dns52.com


But we would like to insert the following data



file: /var/named/dns50.com.db



ns1 14400 IN A 1.1.1.1


file: /var/named/dns51.com.db



ns1 14400 IN A 2.2.2.2


file: /var/named/dns52.com.db



ns1 14400 IN A 3.3.3.3






share|improve this question













marked as duplicate by Jeff Schaller, schily, slm♦ bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Jul 11 at 13:28


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















    up vote
    1
    down vote

    favorite













    This question already has an answer here:



    • Inserting A records in dns zone [closed]

      2 answers



    Any feedback will be appreciated.



    I would like to insert the IP address, however the script is inserting the domain name instead of IP.



    File name: file.txt



    dns50.com: 1.1.1.1
    dns51.com: 2.2.2.2
    dns52.com: 3.3.3.3


    Script:



    for x in `cat /root/file.txt | cut -d: -f1` ; do 
    echo "ns1 14400 IN A $x" >> /var/named/$x.db
    done


    Inserted data when running the about script.



    file: /var/named/dns50.com.db



    ns1 14400 IN A dns50.com


    file: /var/named/dns51.com.db



    ns1 14400 IN A dns51.com


    file: /var/named/dns52.com.db



    ns1 14400 IN A dns52.com


    But we would like to insert the following data



    file: /var/named/dns50.com.db



    ns1 14400 IN A 1.1.1.1


    file: /var/named/dns51.com.db



    ns1 14400 IN A 2.2.2.2


    file: /var/named/dns52.com.db



    ns1 14400 IN A 3.3.3.3






    share|improve this question













    marked as duplicate by Jeff Schaller, schily, slm♦ bash
    Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

    StackExchange.ready(function()
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function()
    $hover.showInfoMessage('',
    messageElement: $msg.clone().show(),
    transient: false,
    position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
    dismissable: false,
    relativeToBody: true
    );
    ,
    function()
    StackExchange.helpers.removeMessages();

    );
    );
    );
    Jul 11 at 13:28


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite












      This question already has an answer here:



      • Inserting A records in dns zone [closed]

        2 answers



      Any feedback will be appreciated.



      I would like to insert the IP address, however the script is inserting the domain name instead of IP.



      File name: file.txt



      dns50.com: 1.1.1.1
      dns51.com: 2.2.2.2
      dns52.com: 3.3.3.3


      Script:



      for x in `cat /root/file.txt | cut -d: -f1` ; do 
      echo "ns1 14400 IN A $x" >> /var/named/$x.db
      done


      Inserted data when running the about script.



      file: /var/named/dns50.com.db



      ns1 14400 IN A dns50.com


      file: /var/named/dns51.com.db



      ns1 14400 IN A dns51.com


      file: /var/named/dns52.com.db



      ns1 14400 IN A dns52.com


      But we would like to insert the following data



      file: /var/named/dns50.com.db



      ns1 14400 IN A 1.1.1.1


      file: /var/named/dns51.com.db



      ns1 14400 IN A 2.2.2.2


      file: /var/named/dns52.com.db



      ns1 14400 IN A 3.3.3.3






      share|improve this question














      This question already has an answer here:



      • Inserting A records in dns zone [closed]

        2 answers



      Any feedback will be appreciated.



      I would like to insert the IP address, however the script is inserting the domain name instead of IP.



      File name: file.txt



      dns50.com: 1.1.1.1
      dns51.com: 2.2.2.2
      dns52.com: 3.3.3.3


      Script:



      for x in `cat /root/file.txt | cut -d: -f1` ; do 
      echo "ns1 14400 IN A $x" >> /var/named/$x.db
      done


      Inserted data when running the about script.



      file: /var/named/dns50.com.db



      ns1 14400 IN A dns50.com


      file: /var/named/dns51.com.db



      ns1 14400 IN A dns51.com


      file: /var/named/dns52.com.db



      ns1 14400 IN A dns52.com


      But we would like to insert the following data



      file: /var/named/dns50.com.db



      ns1 14400 IN A 1.1.1.1


      file: /var/named/dns51.com.db



      ns1 14400 IN A 2.2.2.2


      file: /var/named/dns52.com.db



      ns1 14400 IN A 3.3.3.3




      This question already has an answer here:



      • Inserting A records in dns zone [closed]

        2 answers









      share|improve this question












      share|improve this question




      share|improve this question








      edited Jul 11 at 9:01









      agc

      3,9991935




      3,9991935









      asked Jul 11 at 8:51









      techforever92

      66




      66




      marked as duplicate by Jeff Schaller, schily, slm♦ bash
      Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

      StackExchange.ready(function()
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function()
      $hover.showInfoMessage('',
      messageElement: $msg.clone().show(),
      transient: false,
      position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
      dismissable: false,
      relativeToBody: true
      );
      ,
      function()
      StackExchange.helpers.removeMessages();

      );
      );
      );
      Jul 11 at 13:28


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Jeff Schaller, schily, slm♦ bash
      Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

      StackExchange.ready(function()
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function()
      $hover.showInfoMessage('',
      messageElement: $msg.clone().show(),
      transient: false,
      position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
      dismissable: false,
      relativeToBody: true
      );
      ,
      function()
      StackExchange.helpers.removeMessages();

      );
      );
      );
      Jul 11 at 13:28


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote













          while IFS=': ' read a b ; do 
          echo "ns1 14400 IN A $b" >> /var/named/$a.db
          done





          share|improve this answer





















          • Thank you for your reply. We were able to run it using the below mentioned command # while IFS=': ' read a b ; do echo "ns1 14400 IN A $b" >> /var/named/$a.db; done <file
            – techforever92
            Jul 12 at 6:57


















          up vote
          1
          down vote













          you can try this following awk command.



          awk -F: 'print "ns1 14400 IN A "$2 > $1.db' file.txt





          share|improve this answer




























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            while IFS=': ' read a b ; do 
            echo "ns1 14400 IN A $b" >> /var/named/$a.db
            done





            share|improve this answer





















            • Thank you for your reply. We were able to run it using the below mentioned command # while IFS=': ' read a b ; do echo "ns1 14400 IN A $b" >> /var/named/$a.db; done <file
              – techforever92
              Jul 12 at 6:57















            up vote
            2
            down vote













            while IFS=': ' read a b ; do 
            echo "ns1 14400 IN A $b" >> /var/named/$a.db
            done





            share|improve this answer





















            • Thank you for your reply. We were able to run it using the below mentioned command # while IFS=': ' read a b ; do echo "ns1 14400 IN A $b" >> /var/named/$a.db; done <file
              – techforever92
              Jul 12 at 6:57













            up vote
            2
            down vote










            up vote
            2
            down vote









            while IFS=': ' read a b ; do 
            echo "ns1 14400 IN A $b" >> /var/named/$a.db
            done





            share|improve this answer













            while IFS=': ' read a b ; do 
            echo "ns1 14400 IN A $b" >> /var/named/$a.db
            done






            share|improve this answer













            share|improve this answer



            share|improve this answer











            answered Jul 11 at 9:11









            agc

            3,9991935




            3,9991935











            • Thank you for your reply. We were able to run it using the below mentioned command # while IFS=': ' read a b ; do echo "ns1 14400 IN A $b" >> /var/named/$a.db; done <file
              – techforever92
              Jul 12 at 6:57

















            • Thank you for your reply. We were able to run it using the below mentioned command # while IFS=': ' read a b ; do echo "ns1 14400 IN A $b" >> /var/named/$a.db; done <file
              – techforever92
              Jul 12 at 6:57
















            Thank you for your reply. We were able to run it using the below mentioned command # while IFS=': ' read a b ; do echo "ns1 14400 IN A $b" >> /var/named/$a.db; done <file
            – techforever92
            Jul 12 at 6:57





            Thank you for your reply. We were able to run it using the below mentioned command # while IFS=': ' read a b ; do echo "ns1 14400 IN A $b" >> /var/named/$a.db; done <file
            – techforever92
            Jul 12 at 6:57













            up vote
            1
            down vote













            you can try this following awk command.



            awk -F: 'print "ns1 14400 IN A "$2 > $1.db' file.txt





            share|improve this answer

























              up vote
              1
              down vote













              you can try this following awk command.



              awk -F: 'print "ns1 14400 IN A "$2 > $1.db' file.txt





              share|improve this answer























                up vote
                1
                down vote










                up vote
                1
                down vote









                you can try this following awk command.



                awk -F: 'print "ns1 14400 IN A "$2 > $1.db' file.txt





                share|improve this answer













                you can try this following awk command.



                awk -F: 'print "ns1 14400 IN A "$2 > $1.db' file.txt






                share|improve this answer













                share|improve this answer



                share|improve this answer











                answered Jul 11 at 9:10









                Kamaraj

                2,5341312




                2,5341312












                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay