Using IDs to extract ID headers and add to second column in file B The 2019 Stack Overflow Developer Survey Results Are Incompare columns in a one file and print the count of matchesRemove entire row in a file if first column is repeatedHow to add a column from a file to the last column of another file using awk?how to change one column and add other columns in a row by awkFind multiple matches in a tabular file and print second column?display lines with not more than 4 words in the second columnHow to get the second column from command output?awk print most common string in second columnColumn manipulation using AWKCompare first and second column of two files and print the row from second file if there is a match

The difference between dialogue marks

What did it mean to "align" a radio?

Can you compress metal and what would be the consequences?

What is the closest word meaning "respect for time / mindful"

Identify boardgame from Big movie

Is there any way to tell whether the shot is going to hit you or not?

Apparent duplicates between Haynes service instructions and MOT

What is the accessibility of a package's `Private` context variables?

Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?

STM32 programming and BOOT0 pin

Aging parents with no investments

If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?

Earliest use of the term "Galois extension"?

How to save as into a customized destination on macOS?

Have you ever entered Singapore using a different passport or name?

Falsification in Math vs Science

Right tool to dig six foot holes?

How to answer pointed "are you quitting" questioning when I don't want them to suspect

Return to UK after being refused entry years previously

Loose spokes after only a few rides

What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?

Building a conditional check constraint

Are there any other methods to apply to solving simultaneous equations?

Delete all lines which don't have n characters before delimiter



Using IDs to extract ID headers and add to second column in file B



The 2019 Stack Overflow Developer Survey Results Are Incompare columns in a one file and print the count of matchesRemove entire row in a file if first column is repeatedHow to add a column from a file to the last column of another file using awk?how to change one column and add other columns in a row by awkFind multiple matches in a tabular file and print second column?display lines with not more than 4 words in the second columnHow to get the second column from command output?awk print most common string in second columnColumn manipulation using AWKCompare first and second column of two files and print the row from second file if there is a match



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have a file A that contains accession number family name and name and file B that contains ID and sequences.



I want to use the accession number in B to retrieve the family name and virus name in A and add it to the second column in B.



Example



File A



NC_001348 PEPS Herpesviridae Human herpesvirus 3, complete genome.txt
NC_001350 PEPS Herpesviridae Saimiriine herpesvirus 2 complete genome.txt
NC_001491 PEPS Herpesviridae Equid herpesvirus 1, complete genome.txt
NC_001798 PEPS Herpesviridae Human herpesvirus 2 strain HG52, complete genome.txt
NC_001806 PEPS Herpesviridae Human herpesvirus 1 strain 17, complete genome.txt
NC_001826 PEPS Herpesviridae Murine herpesvirus 68 strain WUMS, complete genome.txt
NC_001844 PEPS Herpesviridae Equid herpesvirus 4, complete genome.txt
NC_001847 PEPS Herpesviridae Bovine herpesvirus 1, complete genome.txt
NC_001987 PEPS Herpesviridae Ateline herpesvirus 3 complete genome.txt
NC_002229 PEPS Herpesviridae Gallid herpesvirus 2, complete genome.txt


File B



NC_001348_71671_71760_KY215944.1 GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA


Expected Output



NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA









share|improve this question









New contributor




Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


























    0















    I have a file A that contains accession number family name and name and file B that contains ID and sequences.



    I want to use the accession number in B to retrieve the family name and virus name in A and add it to the second column in B.



    Example



    File A



    NC_001348 PEPS Herpesviridae Human herpesvirus 3, complete genome.txt
    NC_001350 PEPS Herpesviridae Saimiriine herpesvirus 2 complete genome.txt
    NC_001491 PEPS Herpesviridae Equid herpesvirus 1, complete genome.txt
    NC_001798 PEPS Herpesviridae Human herpesvirus 2 strain HG52, complete genome.txt
    NC_001806 PEPS Herpesviridae Human herpesvirus 1 strain 17, complete genome.txt
    NC_001826 PEPS Herpesviridae Murine herpesvirus 68 strain WUMS, complete genome.txt
    NC_001844 PEPS Herpesviridae Equid herpesvirus 4, complete genome.txt
    NC_001847 PEPS Herpesviridae Bovine herpesvirus 1, complete genome.txt
    NC_001987 PEPS Herpesviridae Ateline herpesvirus 3 complete genome.txt
    NC_002229 PEPS Herpesviridae Gallid herpesvirus 2, complete genome.txt


    File B



    NC_001348_71671_71760_KY215944.1 GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
    NC_001350_89668_89757_HQ221963.1 CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
    NC_001491_126502_126591_AF480884.1 AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
    NC_001798_97563_97652_AY714813.1 CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
    NC_001806_196955_197044_FJ483970.2 TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA


    Expected Output



    NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
    NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
    NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
    NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
    NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA









    share|improve this question









    New contributor




    Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      0












      0








      0








      I have a file A that contains accession number family name and name and file B that contains ID and sequences.



      I want to use the accession number in B to retrieve the family name and virus name in A and add it to the second column in B.



      Example



      File A



      NC_001348 PEPS Herpesviridae Human herpesvirus 3, complete genome.txt
      NC_001350 PEPS Herpesviridae Saimiriine herpesvirus 2 complete genome.txt
      NC_001491 PEPS Herpesviridae Equid herpesvirus 1, complete genome.txt
      NC_001798 PEPS Herpesviridae Human herpesvirus 2 strain HG52, complete genome.txt
      NC_001806 PEPS Herpesviridae Human herpesvirus 1 strain 17, complete genome.txt
      NC_001826 PEPS Herpesviridae Murine herpesvirus 68 strain WUMS, complete genome.txt
      NC_001844 PEPS Herpesviridae Equid herpesvirus 4, complete genome.txt
      NC_001847 PEPS Herpesviridae Bovine herpesvirus 1, complete genome.txt
      NC_001987 PEPS Herpesviridae Ateline herpesvirus 3 complete genome.txt
      NC_002229 PEPS Herpesviridae Gallid herpesvirus 2, complete genome.txt


      File B



      NC_001348_71671_71760_KY215944.1 GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
      NC_001350_89668_89757_HQ221963.1 CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
      NC_001491_126502_126591_AF480884.1 AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
      NC_001798_97563_97652_AY714813.1 CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
      NC_001806_196955_197044_FJ483970.2 TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA


      Expected Output



      NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
      NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
      NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
      NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
      NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA









      share|improve this question









      New contributor




      Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I have a file A that contains accession number family name and name and file B that contains ID and sequences.



      I want to use the accession number in B to retrieve the family name and virus name in A and add it to the second column in B.



      Example



      File A



      NC_001348 PEPS Herpesviridae Human herpesvirus 3, complete genome.txt
      NC_001350 PEPS Herpesviridae Saimiriine herpesvirus 2 complete genome.txt
      NC_001491 PEPS Herpesviridae Equid herpesvirus 1, complete genome.txt
      NC_001798 PEPS Herpesviridae Human herpesvirus 2 strain HG52, complete genome.txt
      NC_001806 PEPS Herpesviridae Human herpesvirus 1 strain 17, complete genome.txt
      NC_001826 PEPS Herpesviridae Murine herpesvirus 68 strain WUMS, complete genome.txt
      NC_001844 PEPS Herpesviridae Equid herpesvirus 4, complete genome.txt
      NC_001847 PEPS Herpesviridae Bovine herpesvirus 1, complete genome.txt
      NC_001987 PEPS Herpesviridae Ateline herpesvirus 3 complete genome.txt
      NC_002229 PEPS Herpesviridae Gallid herpesvirus 2, complete genome.txt


      File B



      NC_001348_71671_71760_KY215944.1 GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
      NC_001350_89668_89757_HQ221963.1 CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
      NC_001491_126502_126591_AF480884.1 AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
      NC_001798_97563_97652_AY714813.1 CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
      NC_001806_196955_197044_FJ483970.2 TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA


      Expected Output



      NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
      NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
      NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
      NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
      NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA






      awk python3






      share|improve this question









      New contributor




      Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 2 days ago









      Kusalananda

      141k17262438




      141k17262438






      New contributor




      Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 days ago









      IbkIbk

      31




      31




      New contributor




      Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes


















          0














          Command:



          c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"


          output



          c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
          NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
          NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
          NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
          NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
          NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA





          share|improve this answer























          • Thanks Praveen Kumar BS, it works perfectly. I won't mind a python script too

            – Ibk
            2 days ago











          • Will post in python too KIndly upvote my answer

            – Praveen Kumar BS
            2 days ago











          • Hi Kumar, its like there is a little glitch.

            – Ibk
            2 days ago











          • Hi Kumar, Its like there is a little glitch. File A and B are not perfect match. The first nine characters of each line in File B are supposed to run through file A which are unique, then return the name of the accession number after PEPS and add it as second column to file B to form a new file.

            – Ibk
            2 days ago











          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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
          );



          );






          Ibk is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511295%2fusing-ids-to-extract-id-headers-and-add-to-second-column-in-file-b%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









          0














          Command:



          c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"


          output



          c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
          NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
          NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
          NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
          NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
          NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA





          share|improve this answer























          • Thanks Praveen Kumar BS, it works perfectly. I won't mind a python script too

            – Ibk
            2 days ago











          • Will post in python too KIndly upvote my answer

            – Praveen Kumar BS
            2 days ago











          • Hi Kumar, its like there is a little glitch.

            – Ibk
            2 days ago











          • Hi Kumar, Its like there is a little glitch. File A and B are not perfect match. The first nine characters of each line in File B are supposed to run through file A which are unique, then return the name of the accession number after PEPS and add it as second column to file B to form a new file.

            – Ibk
            2 days ago















          0














          Command:



          c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"


          output



          c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
          NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
          NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
          NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
          NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
          NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA





          share|improve this answer























          • Thanks Praveen Kumar BS, it works perfectly. I won't mind a python script too

            – Ibk
            2 days ago











          • Will post in python too KIndly upvote my answer

            – Praveen Kumar BS
            2 days ago











          • Hi Kumar, its like there is a little glitch.

            – Ibk
            2 days ago











          • Hi Kumar, Its like there is a little glitch. File A and B are not perfect match. The first nine characters of each line in File B are supposed to run through file A which are unique, then return the name of the accession number after PEPS and add it as second column to file B to form a new file.

            – Ibk
            2 days ago













          0












          0








          0







          Command:



          c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"


          output



          c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
          NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
          NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
          NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
          NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
          NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA





          share|improve this answer













          Command:



          c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"


          output



          c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
          NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
          NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
          NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
          NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
          NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          Praveen Kumar BSPraveen Kumar BS

          1,7641311




          1,7641311












          • Thanks Praveen Kumar BS, it works perfectly. I won't mind a python script too

            – Ibk
            2 days ago











          • Will post in python too KIndly upvote my answer

            – Praveen Kumar BS
            2 days ago











          • Hi Kumar, its like there is a little glitch.

            – Ibk
            2 days ago











          • Hi Kumar, Its like there is a little glitch. File A and B are not perfect match. The first nine characters of each line in File B are supposed to run through file A which are unique, then return the name of the accession number after PEPS and add it as second column to file B to form a new file.

            – Ibk
            2 days ago

















          • Thanks Praveen Kumar BS, it works perfectly. I won't mind a python script too

            – Ibk
            2 days ago











          • Will post in python too KIndly upvote my answer

            – Praveen Kumar BS
            2 days ago











          • Hi Kumar, its like there is a little glitch.

            – Ibk
            2 days ago











          • Hi Kumar, Its like there is a little glitch. File A and B are not perfect match. The first nine characters of each line in File B are supposed to run through file A which are unique, then return the name of the accession number after PEPS and add it as second column to file B to form a new file.

            – Ibk
            2 days ago
















          Thanks Praveen Kumar BS, it works perfectly. I won't mind a python script too

          – Ibk
          2 days ago





          Thanks Praveen Kumar BS, it works perfectly. I won't mind a python script too

          – Ibk
          2 days ago













          Will post in python too KIndly upvote my answer

          – Praveen Kumar BS
          2 days ago





          Will post in python too KIndly upvote my answer

          – Praveen Kumar BS
          2 days ago













          Hi Kumar, its like there is a little glitch.

          – Ibk
          2 days ago





          Hi Kumar, its like there is a little glitch.

          – Ibk
          2 days ago













          Hi Kumar, Its like there is a little glitch. File A and B are not perfect match. The first nine characters of each line in File B are supposed to run through file A which are unique, then return the name of the accession number after PEPS and add it as second column to file B to form a new file.

          – Ibk
          2 days ago





          Hi Kumar, Its like there is a little glitch. File A and B are not perfect match. The first nine characters of each line in File B are supposed to run through file A which are unique, then return the name of the accession number after PEPS and add it as second column to file B to form a new file.

          – Ibk
          2 days ago










          Ibk is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          Ibk is a new contributor. Be nice, and check out our Code of Conduct.












          Ibk is a new contributor. Be nice, and check out our Code of Conduct.











          Ibk is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • 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%2funix.stackexchange.com%2fquestions%2f511295%2fusing-ids-to-extract-id-headers-and-add-to-second-column-in-file-b%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







          -awk, python3

          Popular posts from this blog

          Creating 100m^2 grid automatically using QGIS?Creating grid constrained within polygon in QGIS?Createing polygon layer from point data using QGIS?Creating vector grid using QGIS?Creating grid polygons from coordinates using R or PythonCreating grid from spatio temporal point data?Creating fields in attributes table using other layers using QGISCreate .shp vector grid in QGISQGIS Creating 4km point grid within polygonsCreate a vector grid over a raster layerVector Grid Creates just one grid

          Why is this plane circling around the Lucknow airport every day?Why do aircraft on Flight Radar 24 jump around randomly sometimes?What airport has this walkway over a taxiway?How does Chicago O'Hare's tower sequence aircraft at peak capacity?Which airport is featured in this Delta commercial?After a crash, for how long is the airport closed?Can a passenger plane stand still in the air, or hover at a fixed location above a ground?What are those trucks towing around, and why?What is this airport outside of Cairo, Egypt?Which US airport has the lowest circling MDH?What is this airport video?

          What is this called? Old film camera viewer?What makes a good film camera?What to do with an old film camera?What should one look for when buying a used film camera?What is the value and age of this pre-1967 Ricoh 35 mm camera?DSLR recommendation, question about old Canon 35mm film Camera & lensesCan anyone identify the silver rangefinder-style camera in this advertisement?What kind of a Polaroid 600-camera is this?Will an old film camera still work even when not used in a very long time?What is this camera / Can I develop the film?How to fit an action camera into antique (bellows) housing?What to check when buying used and old film bodies?