tab separation of the file












3















I have a file with seq likes this



ATCGTTTCTCAGCCTTTTGGCAAGACCAAGTGTAGTATCTGTTCTTATCAGATATTGGTATCTGCAGGCACTCCTGGAACCAAT
ATCACTTCTCAACCTTTTGACTAAGATCAAGTGTAATATCTATCTTTATCAGTTTAATATCTGAGATCTCCTTTATCTGAGGACAATATATTTAATGGATTTTTGGAACAGAGAGAAGGAATAGGAGCTTGTCCTGTCCACTCCATGCATTGACCTGGTATTGCAGGACCTCCAGAAACACCACCCCCTCC
ACGCATTATCCGCCTATTGGCTAAAAACAAATGTAGTATCTGTTCCTATCAGTTAAAGCATCAAATGTGGTCTCTAAGTTCAGGGAATTAAATTAATATTTGGAATTGGGAGATGGTTTGGGAGCTTGCTCTATCCTCTCCATGCCTCAGCATGTAATTGCAATGCTTTCAGGAGTGGTGCATTCCTT


It has 3 lines.
I want for each line each letter gets separated by tab and then want to store it in another file. How can i do it.










share|improve this question




















  • 2





    With such questions you should always give an example for the expected output.

    – Hauke Laging
    Dec 17 '14 at 22:41











  • It's a DNA sequence... How long is the strand? ie you should split tabs at the end of the chain. Add more info as Hauke states.

    – eyoung100
    Dec 17 '14 at 23:05


















3















I have a file with seq likes this



ATCGTTTCTCAGCCTTTTGGCAAGACCAAGTGTAGTATCTGTTCTTATCAGATATTGGTATCTGCAGGCACTCCTGGAACCAAT
ATCACTTCTCAACCTTTTGACTAAGATCAAGTGTAATATCTATCTTTATCAGTTTAATATCTGAGATCTCCTTTATCTGAGGACAATATATTTAATGGATTTTTGGAACAGAGAGAAGGAATAGGAGCTTGTCCTGTCCACTCCATGCATTGACCTGGTATTGCAGGACCTCCAGAAACACCACCCCCTCC
ACGCATTATCCGCCTATTGGCTAAAAACAAATGTAGTATCTGTTCCTATCAGTTAAAGCATCAAATGTGGTCTCTAAGTTCAGGGAATTAAATTAATATTTGGAATTGGGAGATGGTTTGGGAGCTTGCTCTATCCTCTCCATGCCTCAGCATGTAATTGCAATGCTTTCAGGAGTGGTGCATTCCTT


It has 3 lines.
I want for each line each letter gets separated by tab and then want to store it in another file. How can i do it.










share|improve this question




















  • 2





    With such questions you should always give an example for the expected output.

    – Hauke Laging
    Dec 17 '14 at 22:41











  • It's a DNA sequence... How long is the strand? ie you should split tabs at the end of the chain. Add more info as Hauke states.

    – eyoung100
    Dec 17 '14 at 23:05
















3












3








3








I have a file with seq likes this



ATCGTTTCTCAGCCTTTTGGCAAGACCAAGTGTAGTATCTGTTCTTATCAGATATTGGTATCTGCAGGCACTCCTGGAACCAAT
ATCACTTCTCAACCTTTTGACTAAGATCAAGTGTAATATCTATCTTTATCAGTTTAATATCTGAGATCTCCTTTATCTGAGGACAATATATTTAATGGATTTTTGGAACAGAGAGAAGGAATAGGAGCTTGTCCTGTCCACTCCATGCATTGACCTGGTATTGCAGGACCTCCAGAAACACCACCCCCTCC
ACGCATTATCCGCCTATTGGCTAAAAACAAATGTAGTATCTGTTCCTATCAGTTAAAGCATCAAATGTGGTCTCTAAGTTCAGGGAATTAAATTAATATTTGGAATTGGGAGATGGTTTGGGAGCTTGCTCTATCCTCTCCATGCCTCAGCATGTAATTGCAATGCTTTCAGGAGTGGTGCATTCCTT


It has 3 lines.
I want for each line each letter gets separated by tab and then want to store it in another file. How can i do it.










share|improve this question
















I have a file with seq likes this



ATCGTTTCTCAGCCTTTTGGCAAGACCAAGTGTAGTATCTGTTCTTATCAGATATTGGTATCTGCAGGCACTCCTGGAACCAAT
ATCACTTCTCAACCTTTTGACTAAGATCAAGTGTAATATCTATCTTTATCAGTTTAATATCTGAGATCTCCTTTATCTGAGGACAATATATTTAATGGATTTTTGGAACAGAGAGAAGGAATAGGAGCTTGTCCTGTCCACTCCATGCATTGACCTGGTATTGCAGGACCTCCAGAAACACCACCCCCTCC
ACGCATTATCCGCCTATTGGCTAAAAACAAATGTAGTATCTGTTCCTATCAGTTAAAGCATCAAATGTGGTCTCTAAGTTCAGGGAATTAAATTAATATTTGGAATTGGGAGATGGTTTGGGAGCTTGCTCTATCCTCTCCATGCCTCAGCATGTAATTGCAATGCTTTCAGGAGTGGTGCATTCCTT


It has 3 lines.
I want for each line each letter gets separated by tab and then want to store it in another file. How can i do it.







text-processing sed awk






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago









Rui F Ribeiro

41.3k1481140




41.3k1481140










asked Dec 17 '14 at 22:38









user3138373user3138373

89041630




89041630








  • 2





    With such questions you should always give an example for the expected output.

    – Hauke Laging
    Dec 17 '14 at 22:41











  • It's a DNA sequence... How long is the strand? ie you should split tabs at the end of the chain. Add more info as Hauke states.

    – eyoung100
    Dec 17 '14 at 23:05
















  • 2





    With such questions you should always give an example for the expected output.

    – Hauke Laging
    Dec 17 '14 at 22:41











  • It's a DNA sequence... How long is the strand? ie you should split tabs at the end of the chain. Add more info as Hauke states.

    – eyoung100
    Dec 17 '14 at 23:05










2




2





With such questions you should always give an example for the expected output.

– Hauke Laging
Dec 17 '14 at 22:41





With such questions you should always give an example for the expected output.

– Hauke Laging
Dec 17 '14 at 22:41













It's a DNA sequence... How long is the strand? ie you should split tabs at the end of the chain. Add more info as Hauke states.

– eyoung100
Dec 17 '14 at 23:05







It's a DNA sequence... How long is the strand? ie you should split tabs at the end of the chain. Add more info as Hauke states.

– eyoung100
Dec 17 '14 at 23:05












4 Answers
4






active

oldest

votes


















5














If I have understood your intention correctly then this does it:



sed -e 's/./&t/g' -e $'s/t$//' file


The second replacement deletes the tab at the end of the line.






share|improve this answer

































    2














    Try doing this using perl:



    perl -ne 'print join "t", split //' file > new_file





    share|improve this answer


























    • If you like golf: perl -ne '$,="t";print split//' file > new_file

      – Joseph R.
      Dec 18 '14 at 5:00



















    2














    In awk:



    awk -F '' -vOFS='t' '{$1=$1}1' file > new_file


    Borrowed the idiom {$1=$1}1 from an answer to one of your other questions.



    This sets the field separator to nothing (-F ''), which means that each record is read character-by-character. The output field separator is set to a TAB character (-vOFS='t') and the idiom {$1=$1}1 is (as far as I can tell) a no-op that has the side effect of causing awk to insert the OFS between every two fields before printing them all.






    share|improve this answer


























    • pretty good. not everybody breaks it down by arguments. someday I'll learn how to use awk probably - and I'll need it broken down that way I expect. thanks.

      – mikeserv
      Dec 18 '14 at 4:52








    • 1





      @mikeserv Thanks. I have promised myself to learn proper awk one day, too :)

      – Joseph R.
      Dec 18 '14 at 4:53











    • I wonder if that {$1=$1}1 thing is anything like sed's s/.{0,1}/ /g? You know - matching the null field between the strings? That's pretty cool, anyway.

      – mikeserv
      Dec 18 '14 at 4:56








    • 1





      @mikeserv Probably not. As far as I can tell, $1=$1 doesn't do anything but tricks awk into thinking the first field has been re-assigned so that it knows to insert the OFS between adjacent fields. The 1 at the end is to simply return a "true" value and cause awk to print the current record by default.

      – Joseph R.
      Dec 18 '14 at 4:58



















    1














    I think you should give fold a go:



    tr \n \r <infile | fold -w1 | tr 'rn'  'nt' >outfile


    I preprocess fold's input w/ tr by replacing the instream newline characters w/ returns. fold is printing a newline character for every column in input - each of your capital letters - but it resets its counter on returns and so when tr does the final post-processing and converts fold's newlines to tabs there are no extra tab characters in output. The output is three lines with a tab character following each character but the last on each line.






    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',
      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
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f174755%2ftab-separation-of-the-file%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      5














      If I have understood your intention correctly then this does it:



      sed -e 's/./&t/g' -e $'s/t$//' file


      The second replacement deletes the tab at the end of the line.






      share|improve this answer






























        5














        If I have understood your intention correctly then this does it:



        sed -e 's/./&t/g' -e $'s/t$//' file


        The second replacement deletes the tab at the end of the line.






        share|improve this answer




























          5












          5








          5







          If I have understood your intention correctly then this does it:



          sed -e 's/./&t/g' -e $'s/t$//' file


          The second replacement deletes the tab at the end of the line.






          share|improve this answer















          If I have understood your intention correctly then this does it:



          sed -e 's/./&t/g' -e $'s/t$//' file


          The second replacement deletes the tab at the end of the line.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 18 '14 at 0:40

























          answered Dec 17 '14 at 22:41









          Hauke LagingHauke Laging

          57.2k1287135




          57.2k1287135

























              2














              Try doing this using perl:



              perl -ne 'print join "t", split //' file > new_file





              share|improve this answer


























              • If you like golf: perl -ne '$,="t";print split//' file > new_file

                – Joseph R.
                Dec 18 '14 at 5:00
















              2














              Try doing this using perl:



              perl -ne 'print join "t", split //' file > new_file





              share|improve this answer


























              • If you like golf: perl -ne '$,="t";print split//' file > new_file

                – Joseph R.
                Dec 18 '14 at 5:00














              2












              2








              2







              Try doing this using perl:



              perl -ne 'print join "t", split //' file > new_file





              share|improve this answer















              Try doing this using perl:



              perl -ne 'print join "t", split //' file > new_file






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Dec 17 '14 at 22:48

























              answered Dec 17 '14 at 22:41









              Gilles QuenotGilles Quenot

              16.3k14053




              16.3k14053













              • If you like golf: perl -ne '$,="t";print split//' file > new_file

                – Joseph R.
                Dec 18 '14 at 5:00



















              • If you like golf: perl -ne '$,="t";print split//' file > new_file

                – Joseph R.
                Dec 18 '14 at 5:00

















              If you like golf: perl -ne '$,="t";print split//' file > new_file

              – Joseph R.
              Dec 18 '14 at 5:00





              If you like golf: perl -ne '$,="t";print split//' file > new_file

              – Joseph R.
              Dec 18 '14 at 5:00











              2














              In awk:



              awk -F '' -vOFS='t' '{$1=$1}1' file > new_file


              Borrowed the idiom {$1=$1}1 from an answer to one of your other questions.



              This sets the field separator to nothing (-F ''), which means that each record is read character-by-character. The output field separator is set to a TAB character (-vOFS='t') and the idiom {$1=$1}1 is (as far as I can tell) a no-op that has the side effect of causing awk to insert the OFS between every two fields before printing them all.






              share|improve this answer


























              • pretty good. not everybody breaks it down by arguments. someday I'll learn how to use awk probably - and I'll need it broken down that way I expect. thanks.

                – mikeserv
                Dec 18 '14 at 4:52








              • 1





                @mikeserv Thanks. I have promised myself to learn proper awk one day, too :)

                – Joseph R.
                Dec 18 '14 at 4:53











              • I wonder if that {$1=$1}1 thing is anything like sed's s/.{0,1}/ /g? You know - matching the null field between the strings? That's pretty cool, anyway.

                – mikeserv
                Dec 18 '14 at 4:56








              • 1





                @mikeserv Probably not. As far as I can tell, $1=$1 doesn't do anything but tricks awk into thinking the first field has been re-assigned so that it knows to insert the OFS between adjacent fields. The 1 at the end is to simply return a "true" value and cause awk to print the current record by default.

                – Joseph R.
                Dec 18 '14 at 4:58
















              2














              In awk:



              awk -F '' -vOFS='t' '{$1=$1}1' file > new_file


              Borrowed the idiom {$1=$1}1 from an answer to one of your other questions.



              This sets the field separator to nothing (-F ''), which means that each record is read character-by-character. The output field separator is set to a TAB character (-vOFS='t') and the idiom {$1=$1}1 is (as far as I can tell) a no-op that has the side effect of causing awk to insert the OFS between every two fields before printing them all.






              share|improve this answer


























              • pretty good. not everybody breaks it down by arguments. someday I'll learn how to use awk probably - and I'll need it broken down that way I expect. thanks.

                – mikeserv
                Dec 18 '14 at 4:52








              • 1





                @mikeserv Thanks. I have promised myself to learn proper awk one day, too :)

                – Joseph R.
                Dec 18 '14 at 4:53











              • I wonder if that {$1=$1}1 thing is anything like sed's s/.{0,1}/ /g? You know - matching the null field between the strings? That's pretty cool, anyway.

                – mikeserv
                Dec 18 '14 at 4:56








              • 1





                @mikeserv Probably not. As far as I can tell, $1=$1 doesn't do anything but tricks awk into thinking the first field has been re-assigned so that it knows to insert the OFS between adjacent fields. The 1 at the end is to simply return a "true" value and cause awk to print the current record by default.

                – Joseph R.
                Dec 18 '14 at 4:58














              2












              2








              2







              In awk:



              awk -F '' -vOFS='t' '{$1=$1}1' file > new_file


              Borrowed the idiom {$1=$1}1 from an answer to one of your other questions.



              This sets the field separator to nothing (-F ''), which means that each record is read character-by-character. The output field separator is set to a TAB character (-vOFS='t') and the idiom {$1=$1}1 is (as far as I can tell) a no-op that has the side effect of causing awk to insert the OFS between every two fields before printing them all.






              share|improve this answer















              In awk:



              awk -F '' -vOFS='t' '{$1=$1}1' file > new_file


              Borrowed the idiom {$1=$1}1 from an answer to one of your other questions.



              This sets the field separator to nothing (-F ''), which means that each record is read character-by-character. The output field separator is set to a TAB character (-vOFS='t') and the idiom {$1=$1}1 is (as far as I can tell) a no-op that has the side effect of causing awk to insert the OFS between every two fields before printing them all.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Apr 13 '17 at 12:36









              Community

              1




              1










              answered Dec 18 '14 at 4:49









              Joseph R.Joseph R.

              28.6k375116




              28.6k375116













              • pretty good. not everybody breaks it down by arguments. someday I'll learn how to use awk probably - and I'll need it broken down that way I expect. thanks.

                – mikeserv
                Dec 18 '14 at 4:52








              • 1





                @mikeserv Thanks. I have promised myself to learn proper awk one day, too :)

                – Joseph R.
                Dec 18 '14 at 4:53











              • I wonder if that {$1=$1}1 thing is anything like sed's s/.{0,1}/ /g? You know - matching the null field between the strings? That's pretty cool, anyway.

                – mikeserv
                Dec 18 '14 at 4:56








              • 1





                @mikeserv Probably not. As far as I can tell, $1=$1 doesn't do anything but tricks awk into thinking the first field has been re-assigned so that it knows to insert the OFS between adjacent fields. The 1 at the end is to simply return a "true" value and cause awk to print the current record by default.

                – Joseph R.
                Dec 18 '14 at 4:58



















              • pretty good. not everybody breaks it down by arguments. someday I'll learn how to use awk probably - and I'll need it broken down that way I expect. thanks.

                – mikeserv
                Dec 18 '14 at 4:52








              • 1





                @mikeserv Thanks. I have promised myself to learn proper awk one day, too :)

                – Joseph R.
                Dec 18 '14 at 4:53











              • I wonder if that {$1=$1}1 thing is anything like sed's s/.{0,1}/ /g? You know - matching the null field between the strings? That's pretty cool, anyway.

                – mikeserv
                Dec 18 '14 at 4:56








              • 1





                @mikeserv Probably not. As far as I can tell, $1=$1 doesn't do anything but tricks awk into thinking the first field has been re-assigned so that it knows to insert the OFS between adjacent fields. The 1 at the end is to simply return a "true" value and cause awk to print the current record by default.

                – Joseph R.
                Dec 18 '14 at 4:58

















              pretty good. not everybody breaks it down by arguments. someday I'll learn how to use awk probably - and I'll need it broken down that way I expect. thanks.

              – mikeserv
              Dec 18 '14 at 4:52







              pretty good. not everybody breaks it down by arguments. someday I'll learn how to use awk probably - and I'll need it broken down that way I expect. thanks.

              – mikeserv
              Dec 18 '14 at 4:52






              1




              1





              @mikeserv Thanks. I have promised myself to learn proper awk one day, too :)

              – Joseph R.
              Dec 18 '14 at 4:53





              @mikeserv Thanks. I have promised myself to learn proper awk one day, too :)

              – Joseph R.
              Dec 18 '14 at 4:53













              I wonder if that {$1=$1}1 thing is anything like sed's s/.{0,1}/ /g? You know - matching the null field between the strings? That's pretty cool, anyway.

              – mikeserv
              Dec 18 '14 at 4:56







              I wonder if that {$1=$1}1 thing is anything like sed's s/.{0,1}/ /g? You know - matching the null field between the strings? That's pretty cool, anyway.

              – mikeserv
              Dec 18 '14 at 4:56






              1




              1





              @mikeserv Probably not. As far as I can tell, $1=$1 doesn't do anything but tricks awk into thinking the first field has been re-assigned so that it knows to insert the OFS between adjacent fields. The 1 at the end is to simply return a "true" value and cause awk to print the current record by default.

              – Joseph R.
              Dec 18 '14 at 4:58





              @mikeserv Probably not. As far as I can tell, $1=$1 doesn't do anything but tricks awk into thinking the first field has been re-assigned so that it knows to insert the OFS between adjacent fields. The 1 at the end is to simply return a "true" value and cause awk to print the current record by default.

              – Joseph R.
              Dec 18 '14 at 4:58











              1














              I think you should give fold a go:



              tr \n \r <infile | fold -w1 | tr 'rn'  'nt' >outfile


              I preprocess fold's input w/ tr by replacing the instream newline characters w/ returns. fold is printing a newline character for every column in input - each of your capital letters - but it resets its counter on returns and so when tr does the final post-processing and converts fold's newlines to tabs there are no extra tab characters in output. The output is three lines with a tab character following each character but the last on each line.






              share|improve this answer




























                1














                I think you should give fold a go:



                tr \n \r <infile | fold -w1 | tr 'rn'  'nt' >outfile


                I preprocess fold's input w/ tr by replacing the instream newline characters w/ returns. fold is printing a newline character for every column in input - each of your capital letters - but it resets its counter on returns and so when tr does the final post-processing and converts fold's newlines to tabs there are no extra tab characters in output. The output is three lines with a tab character following each character but the last on each line.






                share|improve this answer


























                  1












                  1








                  1







                  I think you should give fold a go:



                  tr \n \r <infile | fold -w1 | tr 'rn'  'nt' >outfile


                  I preprocess fold's input w/ tr by replacing the instream newline characters w/ returns. fold is printing a newline character for every column in input - each of your capital letters - but it resets its counter on returns and so when tr does the final post-processing and converts fold's newlines to tabs there are no extra tab characters in output. The output is three lines with a tab character following each character but the last on each line.






                  share|improve this answer













                  I think you should give fold a go:



                  tr \n \r <infile | fold -w1 | tr 'rn'  'nt' >outfile


                  I preprocess fold's input w/ tr by replacing the instream newline characters w/ returns. fold is printing a newline character for every column in input - each of your capital letters - but it resets its counter on returns and so when tr does the final post-processing and converts fold's newlines to tabs there are no extra tab characters in output. The output is three lines with a tab character following each character but the last on each line.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 18 '14 at 3:41









                  mikeservmikeserv

                  45.8k668160




                  45.8k668160






























                      draft saved

                      draft discarded




















































                      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%2f174755%2ftab-separation-of-the-file%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

                      サソリ

                      広島県道265号伴広島線

                      Setup Asymptote in Texstudio