Gawk partial match

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











up vote
1
down vote

favorite












My gawk script isn't matching all potential results, it's only matching one of them..



Example -



script:



gawk -F: "FNR==NRa[$2]=$1;next $1 in aprint a[$1] FS $2" username.email.txt email.phone.txt > username.phone.txt 


email.phone.txt - contains:



 email@email.com:phoneexample


username.email.txt - contains:



 user1:email@email.com
user131:email@email.com


EXPECTED OUTPUT - should be:



 user1:phoneexample
user131:phoneexample


instead it will only match 1 of the lines containing " email@email.com "



outputting -



 user131:email@email.com









share|improve this question



























    up vote
    1
    down vote

    favorite












    My gawk script isn't matching all potential results, it's only matching one of them..



    Example -



    script:



    gawk -F: "FNR==NRa[$2]=$1;next $1 in aprint a[$1] FS $2" username.email.txt email.phone.txt > username.phone.txt 


    email.phone.txt - contains:



     email@email.com:phoneexample


    username.email.txt - contains:



     user1:email@email.com
    user131:email@email.com


    EXPECTED OUTPUT - should be:



     user1:phoneexample
    user131:phoneexample


    instead it will only match 1 of the lines containing " email@email.com "



    outputting -



     user131:email@email.com









    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      My gawk script isn't matching all potential results, it's only matching one of them..



      Example -



      script:



      gawk -F: "FNR==NRa[$2]=$1;next $1 in aprint a[$1] FS $2" username.email.txt email.phone.txt > username.phone.txt 


      email.phone.txt - contains:



       email@email.com:phoneexample


      username.email.txt - contains:



       user1:email@email.com
      user131:email@email.com


      EXPECTED OUTPUT - should be:



       user1:phoneexample
      user131:phoneexample


      instead it will only match 1 of the lines containing " email@email.com "



      outputting -



       user131:email@email.com









      share|improve this question















      My gawk script isn't matching all potential results, it's only matching one of them..



      Example -



      script:



      gawk -F: "FNR==NRa[$2]=$1;next $1 in aprint a[$1] FS $2" username.email.txt email.phone.txt > username.phone.txt 


      email.phone.txt - contains:



       email@email.com:phoneexample


      username.email.txt - contains:



       user1:email@email.com
      user131:email@email.com


      EXPECTED OUTPUT - should be:



       user1:phoneexample
      user131:phoneexample


      instead it will only match 1 of the lines containing " email@email.com "



      outputting -



       user131:email@email.com






      awk cygwin gawk






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 26 at 21:14









      Jeff Schaller

      32.7k849110




      32.7k849110










      asked Aug 26 at 20:12









      questionaires

      232




      232




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          You might be better off when reversing files and fields:



          awk -F: 'FNR==NRa[$1]=$2;next $2 in aprint $1 FS a[$2]' email.phone.txt username.email.txt
          user1:phoneexample
          user131:phoneexample





          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%2f464958%2fgawk-partial-match%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
            1
            down vote



            accepted










            You might be better off when reversing files and fields:



            awk -F: 'FNR==NRa[$1]=$2;next $2 in aprint $1 FS a[$2]' email.phone.txt username.email.txt
            user1:phoneexample
            user131:phoneexample





            share|improve this answer
























              up vote
              1
              down vote



              accepted










              You might be better off when reversing files and fields:



              awk -F: 'FNR==NRa[$1]=$2;next $2 in aprint $1 FS a[$2]' email.phone.txt username.email.txt
              user1:phoneexample
              user131:phoneexample





              share|improve this answer






















                up vote
                1
                down vote



                accepted







                up vote
                1
                down vote



                accepted






                You might be better off when reversing files and fields:



                awk -F: 'FNR==NRa[$1]=$2;next $2 in aprint $1 FS a[$2]' email.phone.txt username.email.txt
                user1:phoneexample
                user131:phoneexample





                share|improve this answer












                You might be better off when reversing files and fields:



                awk -F: 'FNR==NRa[$1]=$2;next $2 in aprint $1 FS a[$2]' email.phone.txt username.email.txt
                user1:phoneexample
                user131:phoneexample






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 26 at 20:28









                RudiC

                1,2398




                1,2398



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f464958%2fgawk-partial-match%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