Substitute numbers in a random IP address port with space

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











up vote
1
down vote

favorite












I have a file with IP and port numbers. I would like to take out the port number and leave the IP alone.



xyz 10.93.10.13:58160).
xyz 10.93.10.13:58161).
xyz 10.18.104.181:12466).
xyz 10.93.10.13:60585).
wxy 10.93.10.13:60586).
wxy 10.93.10.13:60587).
ADMIN loopback[127.0.0.1]:33955).
ADMIN loopback[127.0.0.1]:33957).
ADMIN loopback[127.0.0.1]:33961).
ADMIN loopback[127.0.0.1]:33962).


expected output



xyz 10.93.10.13
xyz 10.93.10.13
xyz 10.18.104.181
xyz 10.93.10.13
wxy 10.93.10.13
wxy 10.93.10.13
ADMIN loopback[127.0.0.1]
ADMIN loopback[127.0.0.1]
ADMIN loopback[127.0.0.1]
ADMIN loopback[127.0.0.1]


i tried a lame procedure which won't work



cat 1.txt|grep -v [:12312]


thanks










share|improve this question



























    up vote
    1
    down vote

    favorite












    I have a file with IP and port numbers. I would like to take out the port number and leave the IP alone.



    xyz 10.93.10.13:58160).
    xyz 10.93.10.13:58161).
    xyz 10.18.104.181:12466).
    xyz 10.93.10.13:60585).
    wxy 10.93.10.13:60586).
    wxy 10.93.10.13:60587).
    ADMIN loopback[127.0.0.1]:33955).
    ADMIN loopback[127.0.0.1]:33957).
    ADMIN loopback[127.0.0.1]:33961).
    ADMIN loopback[127.0.0.1]:33962).


    expected output



    xyz 10.93.10.13
    xyz 10.93.10.13
    xyz 10.18.104.181
    xyz 10.93.10.13
    wxy 10.93.10.13
    wxy 10.93.10.13
    ADMIN loopback[127.0.0.1]
    ADMIN loopback[127.0.0.1]
    ADMIN loopback[127.0.0.1]
    ADMIN loopback[127.0.0.1]


    i tried a lame procedure which won't work



    cat 1.txt|grep -v [:12312]


    thanks










    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have a file with IP and port numbers. I would like to take out the port number and leave the IP alone.



      xyz 10.93.10.13:58160).
      xyz 10.93.10.13:58161).
      xyz 10.18.104.181:12466).
      xyz 10.93.10.13:60585).
      wxy 10.93.10.13:60586).
      wxy 10.93.10.13:60587).
      ADMIN loopback[127.0.0.1]:33955).
      ADMIN loopback[127.0.0.1]:33957).
      ADMIN loopback[127.0.0.1]:33961).
      ADMIN loopback[127.0.0.1]:33962).


      expected output



      xyz 10.93.10.13
      xyz 10.93.10.13
      xyz 10.18.104.181
      xyz 10.93.10.13
      wxy 10.93.10.13
      wxy 10.93.10.13
      ADMIN loopback[127.0.0.1]
      ADMIN loopback[127.0.0.1]
      ADMIN loopback[127.0.0.1]
      ADMIN loopback[127.0.0.1]


      i tried a lame procedure which won't work



      cat 1.txt|grep -v [:12312]


      thanks










      share|improve this question















      I have a file with IP and port numbers. I would like to take out the port number and leave the IP alone.



      xyz 10.93.10.13:58160).
      xyz 10.93.10.13:58161).
      xyz 10.18.104.181:12466).
      xyz 10.93.10.13:60585).
      wxy 10.93.10.13:60586).
      wxy 10.93.10.13:60587).
      ADMIN loopback[127.0.0.1]:33955).
      ADMIN loopback[127.0.0.1]:33957).
      ADMIN loopback[127.0.0.1]:33961).
      ADMIN loopback[127.0.0.1]:33962).


      expected output



      xyz 10.93.10.13
      xyz 10.93.10.13
      xyz 10.18.104.181
      xyz 10.93.10.13
      wxy 10.93.10.13
      wxy 10.93.10.13
      ADMIN loopback[127.0.0.1]
      ADMIN loopback[127.0.0.1]
      ADMIN loopback[127.0.0.1]
      ADMIN loopback[127.0.0.1]


      i tried a lame procedure which won't work



      cat 1.txt|grep -v [:12312]


      thanks







      text-processing ip-address






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 8 at 18:59









      Jeff Schaller

      32.4k849110




      32.4k849110










      asked Aug 8 at 18:54









      ady6831983

      83




      83




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          First, useless use of cat. Secondly, grep only searches; it does not change anything. You want sed here:



          $ sed -E 's/:[0-9]+.*/ /' input
          xyz 10.93.10.13
          xyz 10.93.10.13
          xyz 10.18.104.181
          xyz 10.93.10.13
          wxy 10.93.10.13
          wxy 10.93.10.13
          ADMIN loopback[127.0.0.1]
          ADMIN loopback[127.0.0.1]
          ADMIN loopback[127.0.0.1]
          ADMIN loopback[127.0.0.1]





          share|improve this answer



























            up vote
            0
            down vote













            sed 's/(.*):.*/1/' filename should do the trick. Match everything before the colon and return that in the substitution.






            share|improve this answer




















              Your Answer







              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "106"
              ;
              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',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f461351%2fsubstitute-numbers-in-a-random-ip-address-port-with-space%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote



              accepted










              First, useless use of cat. Secondly, grep only searches; it does not change anything. You want sed here:



              $ sed -E 's/:[0-9]+.*/ /' input
              xyz 10.93.10.13
              xyz 10.93.10.13
              xyz 10.18.104.181
              xyz 10.93.10.13
              wxy 10.93.10.13
              wxy 10.93.10.13
              ADMIN loopback[127.0.0.1]
              ADMIN loopback[127.0.0.1]
              ADMIN loopback[127.0.0.1]
              ADMIN loopback[127.0.0.1]





              share|improve this answer
























                up vote
                2
                down vote



                accepted










                First, useless use of cat. Secondly, grep only searches; it does not change anything. You want sed here:



                $ sed -E 's/:[0-9]+.*/ /' input
                xyz 10.93.10.13
                xyz 10.93.10.13
                xyz 10.18.104.181
                xyz 10.93.10.13
                wxy 10.93.10.13
                wxy 10.93.10.13
                ADMIN loopback[127.0.0.1]
                ADMIN loopback[127.0.0.1]
                ADMIN loopback[127.0.0.1]
                ADMIN loopback[127.0.0.1]





                share|improve this answer






















                  up vote
                  2
                  down vote



                  accepted







                  up vote
                  2
                  down vote



                  accepted






                  First, useless use of cat. Secondly, grep only searches; it does not change anything. You want sed here:



                  $ sed -E 's/:[0-9]+.*/ /' input
                  xyz 10.93.10.13
                  xyz 10.93.10.13
                  xyz 10.18.104.181
                  xyz 10.93.10.13
                  wxy 10.93.10.13
                  wxy 10.93.10.13
                  ADMIN loopback[127.0.0.1]
                  ADMIN loopback[127.0.0.1]
                  ADMIN loopback[127.0.0.1]
                  ADMIN loopback[127.0.0.1]





                  share|improve this answer












                  First, useless use of cat. Secondly, grep only searches; it does not change anything. You want sed here:



                  $ sed -E 's/:[0-9]+.*/ /' input
                  xyz 10.93.10.13
                  xyz 10.93.10.13
                  xyz 10.18.104.181
                  xyz 10.93.10.13
                  wxy 10.93.10.13
                  wxy 10.93.10.13
                  ADMIN loopback[127.0.0.1]
                  ADMIN loopback[127.0.0.1]
                  ADMIN loopback[127.0.0.1]
                  ADMIN loopback[127.0.0.1]






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 8 at 18:57









                  DopeGhoti

                  41k55080




                  41k55080






















                      up vote
                      0
                      down vote













                      sed 's/(.*):.*/1/' filename should do the trick. Match everything before the colon and return that in the substitution.






                      share|improve this answer
























                        up vote
                        0
                        down vote













                        sed 's/(.*):.*/1/' filename should do the trick. Match everything before the colon and return that in the substitution.






                        share|improve this answer






















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          sed 's/(.*):.*/1/' filename should do the trick. Match everything before the colon and return that in the substitution.






                          share|improve this answer












                          sed 's/(.*):.*/1/' filename should do the trick. Match everything before the colon and return that in the substitution.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Aug 8 at 18:58









                          Doug O'Neal

                          2,6271716




                          2,6271716



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f461351%2fsubstitute-numbers-in-a-random-ip-address-port-with-space%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Popular posts from this blog

                              Peggy Mitchell

                              The Forum (Inglewood, California)

                              Palaiologos