Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Dec 2012
Need to add a new line between string of numbers and letters
>NM0019384ATCGCTGATCGATCGTAGCTAGCTAGCT >NM293850CTCGATCGTGGTAGCTACAGCATC >NR3949785GTCGTCGTAGCTACGACTACGACACTACG
>NM0019384 ATCGCTGATCGATCGTAGCTAGCTAGCT >NM293850 CTCGATCGTGGTAGCTACAGCATC >NR3949785 GTCGTCGTAGCTACGACTACGACACTACG
Any way to do this using sed or any other Linux capable command (doesn't matter which)?
- Join Date
- Apr 2009
- I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
Look up the sed command: man sed. This will let you do that quite nicely. It is designed to process strings like that - generating output files from input files with string substitution. I use it to generate CSV files from OpenTSDB data for our analytics group. The methodology for what you want is very similar. The substitution string would be something like this: s/N[MR][0-9]*/&\n/
Try experimenting a bit. Since you only need one pattern match on each line, this should work just fine. In my example I had to match multiple elements on a line, some the same, and others not, so I had to use sed loop constructs. I did that by creating a bash script that wrote a local sed script to the directory where the data needed to go, and piped the data into sed using the temporary script, then deleted the script when done. As I said, your situation is a lot simpler, so you should not need to go to those extremes.
So, I think you were on the right tracking thinking that sed would work for this.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!