how to remove double strings with sed grep awk

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











up vote
0
down vote

favorite












hello how to remove and clear output ?



test.txt



http://urlcom/longStringxyzABC**|**http://urlcom/longStringxyzABC


i want, | including character deletion after



i want result



http://urlcom/longStringxyzABC


thanks







share|improve this question

























    up vote
    0
    down vote

    favorite












    hello how to remove and clear output ?



    test.txt



    http://urlcom/longStringxyzABC**|**http://urlcom/longStringxyzABC


    i want, | including character deletion after



    i want result



    http://urlcom/longStringxyzABC


    thanks







    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      hello how to remove and clear output ?



      test.txt



      http://urlcom/longStringxyzABC**|**http://urlcom/longStringxyzABC


      i want, | including character deletion after



      i want result



      http://urlcom/longStringxyzABC


      thanks







      share|improve this question













      hello how to remove and clear output ?



      test.txt



      http://urlcom/longStringxyzABC**|**http://urlcom/longStringxyzABC


      i want, | including character deletion after



      i want result



      http://urlcom/longStringxyzABC


      thanks









      share|improve this question












      share|improve this question




      share|improve this question








      edited Jun 26 at 7:22









      Arushix

      9968




      9968









      asked Jun 25 at 22:44









      tioma

      32




      32




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          sed 's/|.*//' test.txt

          grep -oP '.*?(?=|)' test.txt

          awk -F'|' 'print $1' test.txt





          share|improve this answer























          • grep -o outputs both (in general all) matches, which is not desired here.
            – dave_thompson_085
            Jun 26 at 1:58










          • @dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative
            – steeldriver
            Jun 26 at 2:09










          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%2f451873%2fhow-to-remove-double-strings-with-sed-grep-awk%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote



          accepted










          sed 's/|.*//' test.txt

          grep -oP '.*?(?=|)' test.txt

          awk -F'|' 'print $1' test.txt





          share|improve this answer























          • grep -o outputs both (in general all) matches, which is not desired here.
            – dave_thompson_085
            Jun 26 at 1:58










          • @dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative
            – steeldriver
            Jun 26 at 2:09














          up vote
          2
          down vote



          accepted










          sed 's/|.*//' test.txt

          grep -oP '.*?(?=|)' test.txt

          awk -F'|' 'print $1' test.txt





          share|improve this answer























          • grep -o outputs both (in general all) matches, which is not desired here.
            – dave_thompson_085
            Jun 26 at 1:58










          • @dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative
            – steeldriver
            Jun 26 at 2:09












          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          sed 's/|.*//' test.txt

          grep -oP '.*?(?=|)' test.txt

          awk -F'|' 'print $1' test.txt





          share|improve this answer















          sed 's/|.*//' test.txt

          grep -oP '.*?(?=|)' test.txt

          awk -F'|' 'print $1' test.txt






          share|improve this answer















          share|improve this answer



          share|improve this answer








          edited Jun 26 at 2:08


























          answered Jun 25 at 22:53









          steeldriver

          30.9k34877




          30.9k34877











          • grep -o outputs both (in general all) matches, which is not desired here.
            – dave_thompson_085
            Jun 26 at 1:58










          • @dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative
            – steeldriver
            Jun 26 at 2:09
















          • grep -o outputs both (in general all) matches, which is not desired here.
            – dave_thompson_085
            Jun 26 at 1:58










          • @dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative
            – steeldriver
            Jun 26 at 2:09















          grep -o outputs both (in general all) matches, which is not desired here.
          – dave_thompson_085
          Jun 26 at 1:58




          grep -o outputs both (in general all) matches, which is not desired here.
          – dave_thompson_085
          Jun 26 at 1:58












          @dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative
          – steeldriver
          Jun 26 at 2:09




          @dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative
          – steeldriver
          Jun 26 at 2:09












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451873%2fhow-to-remove-double-strings-with-sed-grep-awk%23new-answer', 'question_page');

          );

          Post as a guest













































































          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