简体   繁体   中英

AWK: splitting a string into pieces

I've been trying to solve this problem by myself, I've looked for some help on Google, but I can't go ahead anyway. Any help you can provide will be very thanked!

So, I have a string, for example:

CTGGCAAGAAAGAAATGTGGAATGGCAACAAAGAAAGGAAAAAAAATCAATACTGGCTGATGCAGTTTC

And I'm looking for this output:

CTG GCA AGA AAG AAA TGT GGA ATG GCA ACA AAG AAA GGA AAA AAA ATC AAT ACT GGC TGA TGC AGT TTC

I could do it very fast in Python or Perl, but I need to use here AWK.

Thank you very much, people! I appreciate.

awk '{gsub(/.../,"& ")}1' <<< CTGGCAAGAAAGAAATGTGGAATGGCAACAAAGAAAGGAAAAAAAATCAATACTGGCTGATGCAGTTTC
CTG GCA AGA AAG AAA TGT GGA ATG GCA ACA AAG AAA GGA AAA AAA ATC AAT ACT GGC TGA TGC AGT TTC 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM