Using IDs to extract ID headers and add to second column in file B The 2019 Stack Overflow...

If a poisoned arrow's piercing damage is reduced to 0, do you still get poisoned?

Extreme, unacceptable situation and I can't attend work tomorrow morning

Pristine Bit Checking

What do hard-Brexiteers want with respect to the Irish border?

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

Is this food a bread or a loaf?

Why is Grand Jury testimony secret?

Why do UK politicians seemingly ignore opinion polls on Brexit?

Why don't Unix/Linux systems traverse through directories until they find the required version of a linked library?

Lethal sonic weapons

Inline version of a function returns different value then non-inline version

Inflated grade on resume at previous job, might former employer tell new employer?

In microwave frequencies, do you use a circulator when you need a (near) perfect diode?

Can't find the latex code for the ⍎ (down tack jot) symbol

How to make payment on the internet without leaving a money trail?

How to reverse every other sublist of a list?

How can I fix this gap between bookcases I made?

How was Skylab's orbit inclination chosen?

Inversion Puzzle

Limit the amount of RAM Mathematica may access?

Confusion about non-derivable continuous functions

What tool would a Roman-age civilization have to grind silver and other metals into dust?

Is there a name of the flying bionic bird?

Monty Hall variation



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 yesterday









      Kusalananda

      140k17261436




      140k17261436






      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 yesterday









      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
            yesterday











          • Will post in python too KIndly upvote my answer

            – Praveen Kumar BS
            yesterday











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

            – Ibk
            yesterday











          • 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
            yesterday












          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
            yesterday











          • Will post in python too KIndly upvote my answer

            – Praveen Kumar BS
            yesterday











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

            – Ibk
            yesterday











          • 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
            yesterday
















          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
            yesterday











          • Will post in python too KIndly upvote my answer

            – Praveen Kumar BS
            yesterday











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

            – Ibk
            yesterday











          • 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
            yesterday














          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 yesterday









          Praveen Kumar BSPraveen Kumar BS

          1,7541311




          1,7541311













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

            – Ibk
            yesterday











          • Will post in python too KIndly upvote my answer

            – Praveen Kumar BS
            yesterday











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

            – Ibk
            yesterday











          • 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
            yesterday



















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

            – Ibk
            yesterday











          • Will post in python too KIndly upvote my answer

            – Praveen Kumar BS
            yesterday











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

            – Ibk
            yesterday











          • 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
            yesterday

















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

          – Ibk
          yesterday





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

          – Ibk
          yesterday













          Will post in python too KIndly upvote my answer

          – Praveen Kumar BS
          yesterday





          Will post in python too KIndly upvote my answer

          – Praveen Kumar BS
          yesterday













          Hi Kumar, its like there is a little glitch.

          – Ibk
          yesterday





          Hi Kumar, its like there is a little glitch.

          – Ibk
          yesterday













          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
          yesterday





          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
          yesterday










          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







          Popular posts from this blog

          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

          Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...