bash remote ssh update append replace












2















I can successfully ssh into a remote Linux/Ubuntu machine located on a remote LAN from another Linux/Ubuntu machine located on my local LAN and I can also append the file that I want on the remote machine with my new data using example:



RET_IP="111.111.111.111"
HOSTNAME=system host name
PORT="111"
DEST_FILE="/etc/hosts_2"
echo "$RET_IP $HOSTNAME" | ssh -p $PORT root@hostname "cat >> $DEST_FILE"


The file contents represent an /etc/hosts file. What I can't figure out what to do is how to replace the line for the IP hostname. There may be several entries to the hosts_2 file and even some entries with the same IP address, just different hostname and I want to locate the line with hostname"X" and replace it or if that hostname"X" doesn't exist, I want to add/append the hosts_2 file with the new line.



I do not know if this is possible remotely. Maybe it is not possible remotely. My searches have not found what I need although maybe there is something with sed.










share|improve this question



























    2















    I can successfully ssh into a remote Linux/Ubuntu machine located on a remote LAN from another Linux/Ubuntu machine located on my local LAN and I can also append the file that I want on the remote machine with my new data using example:



    RET_IP="111.111.111.111"
    HOSTNAME=system host name
    PORT="111"
    DEST_FILE="/etc/hosts_2"
    echo "$RET_IP $HOSTNAME" | ssh -p $PORT root@hostname "cat >> $DEST_FILE"


    The file contents represent an /etc/hosts file. What I can't figure out what to do is how to replace the line for the IP hostname. There may be several entries to the hosts_2 file and even some entries with the same IP address, just different hostname and I want to locate the line with hostname"X" and replace it or if that hostname"X" doesn't exist, I want to add/append the hosts_2 file with the new line.



    I do not know if this is possible remotely. Maybe it is not possible remotely. My searches have not found what I need although maybe there is something with sed.










    share|improve this question

























      2












      2








      2








      I can successfully ssh into a remote Linux/Ubuntu machine located on a remote LAN from another Linux/Ubuntu machine located on my local LAN and I can also append the file that I want on the remote machine with my new data using example:



      RET_IP="111.111.111.111"
      HOSTNAME=system host name
      PORT="111"
      DEST_FILE="/etc/hosts_2"
      echo "$RET_IP $HOSTNAME" | ssh -p $PORT root@hostname "cat >> $DEST_FILE"


      The file contents represent an /etc/hosts file. What I can't figure out what to do is how to replace the line for the IP hostname. There may be several entries to the hosts_2 file and even some entries with the same IP address, just different hostname and I want to locate the line with hostname"X" and replace it or if that hostname"X" doesn't exist, I want to add/append the hosts_2 file with the new line.



      I do not know if this is possible remotely. Maybe it is not possible remotely. My searches have not found what I need although maybe there is something with sed.










      share|improve this question














      I can successfully ssh into a remote Linux/Ubuntu machine located on a remote LAN from another Linux/Ubuntu machine located on my local LAN and I can also append the file that I want on the remote machine with my new data using example:



      RET_IP="111.111.111.111"
      HOSTNAME=system host name
      PORT="111"
      DEST_FILE="/etc/hosts_2"
      echo "$RET_IP $HOSTNAME" | ssh -p $PORT root@hostname "cat >> $DEST_FILE"


      The file contents represent an /etc/hosts file. What I can't figure out what to do is how to replace the line for the IP hostname. There may be several entries to the hosts_2 file and even some entries with the same IP address, just different hostname and I want to locate the line with hostname"X" and replace it or if that hostname"X" doesn't exist, I want to add/append the hosts_2 file with the new line.



      I do not know if this is possible remotely. Maybe it is not possible remotely. My searches have not found what I need although maybe there is something with sed.







      bash ssh replace append






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 23 '18 at 19:51









      WesZWesZ

      527




      527
























          1 Answer
          1






          active

          oldest

          votes


















          1














          IP="111.111.111.111"
          ssh_system_hostname="whatever"
          new_hostname="system host name"
          old_hostname="X"
          port="111"
          dest_file="/etc/hosts_2"
          ssh -p $port root@$ssh_system_hostname -i "grep "$IP $old_hostname" $dest_file
          && sed -ie "s:$IP $old_hostname:$IP $new_hostname:g" $dest_file
          || echo "$IP $new_hostname" >> $dest_file"


          Lemme know if this works. I'm not entirely sure I escaped my double quotes correctly.



          Explanation: you ssh as normal, and then you check if the line exists in the file with grep. If that succeeds, you do a substitute with sed for the old thing and replace it with the new thing in that file. If the grep fails (or if the grep succeeds and somehow the sed fails), then append to the file with echo.









          share|improve this answer
























          • Hi Jeremy, I gave it code TEST_IP="111.111.111.111" TEST_HOSTNAME="$HOSTNAME" port="222" IP="222.222.222.222" old_hostname="nanoPCT4" new_hostname="nanoPCT4" dest_file="etc/hosts_2" $new_hostname="Test_Host" and ssh -p $port root@${dUSER[${x}]} -i "grep "$TEST_IP $old_hostname" $dest_file && sed -ie "s:$TEST_IP $old_hostname:$IP $new_hostname:g" $dest_file || echo "$IP $new_hostname" >> $dest_file" and it ssh's fine but returns this:

            – WesZ
            Nov 24 '18 at 9:23













          • nanoPCT4=Test_Host: command not found Warning: Identity file grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:111.111.111.111 nanoPCT4:222.222.222.222 nanoPCT4:g" /etc/hosts_2 || echo "222.222.222.222 nanoPCT4" >> /etc/hosts_2 not accessible: No such file or directory.

            – WesZ
            Nov 24 '18 at 9:28













          • Both of these work from the command line: echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2 sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2

            – WesZ
            Nov 24 '18 at 9:59











          • This also worked fine from the command line. grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2 || echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2

            – WesZ
            Nov 24 '18 at 10:07











          • I was able to log in remotely using the -ssh credentials and successfully execute grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2 || echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2 from the command line. I just can't do it all at the same time.

            – WesZ
            Nov 24 '18 at 10:31











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452270%2fbash-remote-ssh-update-append-replace%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          IP="111.111.111.111"
          ssh_system_hostname="whatever"
          new_hostname="system host name"
          old_hostname="X"
          port="111"
          dest_file="/etc/hosts_2"
          ssh -p $port root@$ssh_system_hostname -i "grep "$IP $old_hostname" $dest_file
          && sed -ie "s:$IP $old_hostname:$IP $new_hostname:g" $dest_file
          || echo "$IP $new_hostname" >> $dest_file"


          Lemme know if this works. I'm not entirely sure I escaped my double quotes correctly.



          Explanation: you ssh as normal, and then you check if the line exists in the file with grep. If that succeeds, you do a substitute with sed for the old thing and replace it with the new thing in that file. If the grep fails (or if the grep succeeds and somehow the sed fails), then append to the file with echo.









          share|improve this answer
























          • Hi Jeremy, I gave it code TEST_IP="111.111.111.111" TEST_HOSTNAME="$HOSTNAME" port="222" IP="222.222.222.222" old_hostname="nanoPCT4" new_hostname="nanoPCT4" dest_file="etc/hosts_2" $new_hostname="Test_Host" and ssh -p $port root@${dUSER[${x}]} -i "grep "$TEST_IP $old_hostname" $dest_file && sed -ie "s:$TEST_IP $old_hostname:$IP $new_hostname:g" $dest_file || echo "$IP $new_hostname" >> $dest_file" and it ssh's fine but returns this:

            – WesZ
            Nov 24 '18 at 9:23













          • nanoPCT4=Test_Host: command not found Warning: Identity file grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:111.111.111.111 nanoPCT4:222.222.222.222 nanoPCT4:g" /etc/hosts_2 || echo "222.222.222.222 nanoPCT4" >> /etc/hosts_2 not accessible: No such file or directory.

            – WesZ
            Nov 24 '18 at 9:28













          • Both of these work from the command line: echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2 sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2

            – WesZ
            Nov 24 '18 at 9:59











          • This also worked fine from the command line. grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2 || echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2

            – WesZ
            Nov 24 '18 at 10:07











          • I was able to log in remotely using the -ssh credentials and successfully execute grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2 || echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2 from the command line. I just can't do it all at the same time.

            – WesZ
            Nov 24 '18 at 10:31
















          1














          IP="111.111.111.111"
          ssh_system_hostname="whatever"
          new_hostname="system host name"
          old_hostname="X"
          port="111"
          dest_file="/etc/hosts_2"
          ssh -p $port root@$ssh_system_hostname -i "grep "$IP $old_hostname" $dest_file
          && sed -ie "s:$IP $old_hostname:$IP $new_hostname:g" $dest_file
          || echo "$IP $new_hostname" >> $dest_file"


          Lemme know if this works. I'm not entirely sure I escaped my double quotes correctly.



          Explanation: you ssh as normal, and then you check if the line exists in the file with grep. If that succeeds, you do a substitute with sed for the old thing and replace it with the new thing in that file. If the grep fails (or if the grep succeeds and somehow the sed fails), then append to the file with echo.









          share|improve this answer
























          • Hi Jeremy, I gave it code TEST_IP="111.111.111.111" TEST_HOSTNAME="$HOSTNAME" port="222" IP="222.222.222.222" old_hostname="nanoPCT4" new_hostname="nanoPCT4" dest_file="etc/hosts_2" $new_hostname="Test_Host" and ssh -p $port root@${dUSER[${x}]} -i "grep "$TEST_IP $old_hostname" $dest_file && sed -ie "s:$TEST_IP $old_hostname:$IP $new_hostname:g" $dest_file || echo "$IP $new_hostname" >> $dest_file" and it ssh's fine but returns this:

            – WesZ
            Nov 24 '18 at 9:23













          • nanoPCT4=Test_Host: command not found Warning: Identity file grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:111.111.111.111 nanoPCT4:222.222.222.222 nanoPCT4:g" /etc/hosts_2 || echo "222.222.222.222 nanoPCT4" >> /etc/hosts_2 not accessible: No such file or directory.

            – WesZ
            Nov 24 '18 at 9:28













          • Both of these work from the command line: echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2 sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2

            – WesZ
            Nov 24 '18 at 9:59











          • This also worked fine from the command line. grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2 || echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2

            – WesZ
            Nov 24 '18 at 10:07











          • I was able to log in remotely using the -ssh credentials and successfully execute grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2 || echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2 from the command line. I just can't do it all at the same time.

            – WesZ
            Nov 24 '18 at 10:31














          1












          1








          1







          IP="111.111.111.111"
          ssh_system_hostname="whatever"
          new_hostname="system host name"
          old_hostname="X"
          port="111"
          dest_file="/etc/hosts_2"
          ssh -p $port root@$ssh_system_hostname -i "grep "$IP $old_hostname" $dest_file
          && sed -ie "s:$IP $old_hostname:$IP $new_hostname:g" $dest_file
          || echo "$IP $new_hostname" >> $dest_file"


          Lemme know if this works. I'm not entirely sure I escaped my double quotes correctly.



          Explanation: you ssh as normal, and then you check if the line exists in the file with grep. If that succeeds, you do a substitute with sed for the old thing and replace it with the new thing in that file. If the grep fails (or if the grep succeeds and somehow the sed fails), then append to the file with echo.









          share|improve this answer













          IP="111.111.111.111"
          ssh_system_hostname="whatever"
          new_hostname="system host name"
          old_hostname="X"
          port="111"
          dest_file="/etc/hosts_2"
          ssh -p $port root@$ssh_system_hostname -i "grep "$IP $old_hostname" $dest_file
          && sed -ie "s:$IP $old_hostname:$IP $new_hostname:g" $dest_file
          || echo "$IP $new_hostname" >> $dest_file"


          Lemme know if this works. I'm not entirely sure I escaped my double quotes correctly.



          Explanation: you ssh as normal, and then you check if the line exists in the file with grep. If that succeeds, you do a substitute with sed for the old thing and replace it with the new thing in that file. If the grep fails (or if the grep succeeds and somehow the sed fails), then append to the file with echo.










          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 24 '18 at 1:16









          jeremysprofilejeremysprofile

          1,7751817




          1,7751817













          • Hi Jeremy, I gave it code TEST_IP="111.111.111.111" TEST_HOSTNAME="$HOSTNAME" port="222" IP="222.222.222.222" old_hostname="nanoPCT4" new_hostname="nanoPCT4" dest_file="etc/hosts_2" $new_hostname="Test_Host" and ssh -p $port root@${dUSER[${x}]} -i "grep "$TEST_IP $old_hostname" $dest_file && sed -ie "s:$TEST_IP $old_hostname:$IP $new_hostname:g" $dest_file || echo "$IP $new_hostname" >> $dest_file" and it ssh's fine but returns this:

            – WesZ
            Nov 24 '18 at 9:23













          • nanoPCT4=Test_Host: command not found Warning: Identity file grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:111.111.111.111 nanoPCT4:222.222.222.222 nanoPCT4:g" /etc/hosts_2 || echo "222.222.222.222 nanoPCT4" >> /etc/hosts_2 not accessible: No such file or directory.

            – WesZ
            Nov 24 '18 at 9:28













          • Both of these work from the command line: echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2 sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2

            – WesZ
            Nov 24 '18 at 9:59











          • This also worked fine from the command line. grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2 || echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2

            – WesZ
            Nov 24 '18 at 10:07











          • I was able to log in remotely using the -ssh credentials and successfully execute grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2 || echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2 from the command line. I just can't do it all at the same time.

            – WesZ
            Nov 24 '18 at 10:31



















          • Hi Jeremy, I gave it code TEST_IP="111.111.111.111" TEST_HOSTNAME="$HOSTNAME" port="222" IP="222.222.222.222" old_hostname="nanoPCT4" new_hostname="nanoPCT4" dest_file="etc/hosts_2" $new_hostname="Test_Host" and ssh -p $port root@${dUSER[${x}]} -i "grep "$TEST_IP $old_hostname" $dest_file && sed -ie "s:$TEST_IP $old_hostname:$IP $new_hostname:g" $dest_file || echo "$IP $new_hostname" >> $dest_file" and it ssh's fine but returns this:

            – WesZ
            Nov 24 '18 at 9:23













          • nanoPCT4=Test_Host: command not found Warning: Identity file grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:111.111.111.111 nanoPCT4:222.222.222.222 nanoPCT4:g" /etc/hosts_2 || echo "222.222.222.222 nanoPCT4" >> /etc/hosts_2 not accessible: No such file or directory.

            – WesZ
            Nov 24 '18 at 9:28













          • Both of these work from the command line: echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2 sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2

            – WesZ
            Nov 24 '18 at 9:59











          • This also worked fine from the command line. grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2 || echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2

            – WesZ
            Nov 24 '18 at 10:07











          • I was able to log in remotely using the -ssh credentials and successfully execute grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2 || echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2 from the command line. I just can't do it all at the same time.

            – WesZ
            Nov 24 '18 at 10:31

















          Hi Jeremy, I gave it code TEST_IP="111.111.111.111" TEST_HOSTNAME="$HOSTNAME" port="222" IP="222.222.222.222" old_hostname="nanoPCT4" new_hostname="nanoPCT4" dest_file="etc/hosts_2" $new_hostname="Test_Host" and ssh -p $port root@${dUSER[${x}]} -i "grep "$TEST_IP $old_hostname" $dest_file && sed -ie "s:$TEST_IP $old_hostname:$IP $new_hostname:g" $dest_file || echo "$IP $new_hostname" >> $dest_file" and it ssh's fine but returns this:

          – WesZ
          Nov 24 '18 at 9:23







          Hi Jeremy, I gave it code TEST_IP="111.111.111.111" TEST_HOSTNAME="$HOSTNAME" port="222" IP="222.222.222.222" old_hostname="nanoPCT4" new_hostname="nanoPCT4" dest_file="etc/hosts_2" $new_hostname="Test_Host" and ssh -p $port root@${dUSER[${x}]} -i "grep "$TEST_IP $old_hostname" $dest_file && sed -ie "s:$TEST_IP $old_hostname:$IP $new_hostname:g" $dest_file || echo "$IP $new_hostname" >> $dest_file" and it ssh's fine but returns this:

          – WesZ
          Nov 24 '18 at 9:23















          nanoPCT4=Test_Host: command not found Warning: Identity file grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:111.111.111.111 nanoPCT4:222.222.222.222 nanoPCT4:g" /etc/hosts_2 || echo "222.222.222.222 nanoPCT4" >> /etc/hosts_2 not accessible: No such file or directory.

          – WesZ
          Nov 24 '18 at 9:28







          nanoPCT4=Test_Host: command not found Warning: Identity file grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:111.111.111.111 nanoPCT4:222.222.222.222 nanoPCT4:g" /etc/hosts_2 || echo "222.222.222.222 nanoPCT4" >> /etc/hosts_2 not accessible: No such file or directory.

          – WesZ
          Nov 24 '18 at 9:28















          Both of these work from the command line: echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2 sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2

          – WesZ
          Nov 24 '18 at 9:59





          Both of these work from the command line: echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2 sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2

          – WesZ
          Nov 24 '18 at 9:59













          This also worked fine from the command line. grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2 || echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2

          – WesZ
          Nov 24 '18 at 10:07





          This also worked fine from the command line. grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2 || echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2

          – WesZ
          Nov 24 '18 at 10:07













          I was able to log in remotely using the -ssh credentials and successfully execute grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2 || echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2 from the command line. I just can't do it all at the same time.

          – WesZ
          Nov 24 '18 at 10:31





          I was able to log in remotely using the -ssh credentials and successfully execute grep "111.111.111.111 nanoPCT4" /etc/hosts_2 && sed -ie "s:333.333.333.333 nanoPCT4:444.444.444.444 nanoPCT4:g" /etc/hosts_2 || echo "333.333.333.333 nanoPCT4" >> /etc/hosts_2 from the command line. I just can't do it all at the same time.

          – WesZ
          Nov 24 '18 at 10:31




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452270%2fbash-remote-ssh-update-append-replace%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin