Comparing two text files

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











up vote
-4
down vote

favorite












I have a text file like this.



2XKJ;2XKK; B0V9T6
2XKJ;2XKK; B0VP98
3TSG; D3X610


and i have another file having PDB IDs.



2XKJ
2XKJ
2XKJ
2XKK


I want a output like this



2XKJ B0V9T6 B0VP98
2XKJ B0V9T6 B0VP98
2XKJ B0V9T6 B0VP98
2XKK B0V9T6 B0VP98


how to get this output using perl , awk or linux







share|improve this question


















  • 1




    why B0VP98 should be skipped?
    – RomanPerekhrest
    Dec 6 '17 at 9:39










  • Ohh so sorry ..the output should be like ..2XKJ B0V9T6 B0VP98 2XKJ B0V9T6 B0VP98 2XKJ B0V9T6 B0VP98 2XKK B0V9T6 B0VP98
    – Tina Sharma
    Dec 6 '17 at 10:03















up vote
-4
down vote

favorite












I have a text file like this.



2XKJ;2XKK; B0V9T6
2XKJ;2XKK; B0VP98
3TSG; D3X610


and i have another file having PDB IDs.



2XKJ
2XKJ
2XKJ
2XKK


I want a output like this



2XKJ B0V9T6 B0VP98
2XKJ B0V9T6 B0VP98
2XKJ B0V9T6 B0VP98
2XKK B0V9T6 B0VP98


how to get this output using perl , awk or linux







share|improve this question


















  • 1




    why B0VP98 should be skipped?
    – RomanPerekhrest
    Dec 6 '17 at 9:39










  • Ohh so sorry ..the output should be like ..2XKJ B0V9T6 B0VP98 2XKJ B0V9T6 B0VP98 2XKJ B0V9T6 B0VP98 2XKK B0V9T6 B0VP98
    – Tina Sharma
    Dec 6 '17 at 10:03













up vote
-4
down vote

favorite









up vote
-4
down vote

favorite











I have a text file like this.



2XKJ;2XKK; B0V9T6
2XKJ;2XKK; B0VP98
3TSG; D3X610


and i have another file having PDB IDs.



2XKJ
2XKJ
2XKJ
2XKK


I want a output like this



2XKJ B0V9T6 B0VP98
2XKJ B0V9T6 B0VP98
2XKJ B0V9T6 B0VP98
2XKK B0V9T6 B0VP98


how to get this output using perl , awk or linux







share|improve this question














I have a text file like this.



2XKJ;2XKK; B0V9T6
2XKJ;2XKK; B0VP98
3TSG; D3X610


and i have another file having PDB IDs.



2XKJ
2XKJ
2XKJ
2XKK


I want a output like this



2XKJ B0V9T6 B0VP98
2XKJ B0V9T6 B0VP98
2XKJ B0V9T6 B0VP98
2XKK B0V9T6 B0VP98


how to get this output using perl , awk or linux









share|improve this question













share|improve this question




share|improve this question








edited Dec 6 '17 at 10:10









Stéphane Chazelas

282k53520854




282k53520854










asked Dec 6 '17 at 9:31









Tina Sharma

271




271







  • 1




    why B0VP98 should be skipped?
    – RomanPerekhrest
    Dec 6 '17 at 9:39










  • Ohh so sorry ..the output should be like ..2XKJ B0V9T6 B0VP98 2XKJ B0V9T6 B0VP98 2XKJ B0V9T6 B0VP98 2XKK B0V9T6 B0VP98
    – Tina Sharma
    Dec 6 '17 at 10:03













  • 1




    why B0VP98 should be skipped?
    – RomanPerekhrest
    Dec 6 '17 at 9:39










  • Ohh so sorry ..the output should be like ..2XKJ B0V9T6 B0VP98 2XKJ B0V9T6 B0VP98 2XKJ B0V9T6 B0VP98 2XKK B0V9T6 B0VP98
    – Tina Sharma
    Dec 6 '17 at 10:03








1




1




why B0VP98 should be skipped?
– RomanPerekhrest
Dec 6 '17 at 9:39




why B0VP98 should be skipped?
– RomanPerekhrest
Dec 6 '17 at 9:39












Ohh so sorry ..the output should be like ..2XKJ B0V9T6 B0VP98 2XKJ B0V9T6 B0VP98 2XKJ B0V9T6 B0VP98 2XKK B0V9T6 B0VP98
– Tina Sharma
Dec 6 '17 at 10:03





Ohh so sorry ..the output should be like ..2XKJ B0V9T6 B0VP98 2XKJ B0V9T6 B0VP98 2XKJ B0V9T6 B0VP98 2XKK B0V9T6 B0VP98
– Tina Sharma
Dec 6 '17 at 10:03











1 Answer
1






active

oldest

votes

















up vote
1
down vote













With awk:



awk -F ';[[:blank:]]*' '
!file1_done for (i = 1; i < NF; i++) val[$i] = val[$i] " " $NF; next
print $1 val[$1]' file1 file1_done=1 file2





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%2f409147%2fcomparing-two-text-files%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













    With awk:



    awk -F ';[[:blank:]]*' '
    !file1_done for (i = 1; i < NF; i++) val[$i] = val[$i] " " $NF; next
    print $1 val[$1]' file1 file1_done=1 file2





    share|improve this answer
























      up vote
      1
      down vote













      With awk:



      awk -F ';[[:blank:]]*' '
      !file1_done for (i = 1; i < NF; i++) val[$i] = val[$i] " " $NF; next
      print $1 val[$1]' file1 file1_done=1 file2





      share|improve this answer






















        up vote
        1
        down vote










        up vote
        1
        down vote









        With awk:



        awk -F ';[[:blank:]]*' '
        !file1_done for (i = 1; i < NF; i++) val[$i] = val[$i] " " $NF; next
        print $1 val[$1]' file1 file1_done=1 file2





        share|improve this answer












        With awk:



        awk -F ';[[:blank:]]*' '
        !file1_done for (i = 1; i < NF; i++) val[$i] = val[$i] " " $NF; next
        print $1 val[$1]' file1 file1_done=1 file2






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 6 '17 at 10:08









        Stéphane Chazelas

        282k53520854




        282k53520854



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f409147%2fcomparing-two-text-files%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