http://qs321.pair.com?node_id=11104909


in reply to change \n to \t

Here's a command-line version (see perlrun) (update: this code processes line-by-line, so it should work on any file — unless a "line" is more than a couple GB long! :). Caution: This only works with Perl versions 5.10+ because it uses the  \K regex operator (see Extended Patterns). If you have a pre-5.10 Perl version, let me know; a simple fix can be had (update: what the heck; the pre-5.10 substitution is  s{ ^ (> \d+) \n }{$1\t}xms with all else the same).

c:\@Work\Perl\monks\yueli711>type 1.fa >1 AGTCGTAGCAT >2 TGAGCTACG >3 GGCATAGN >4 CGCACNCAGCTACACC >5 NGATAGCTACA c:\@Work\Perl\monks\yueli711>perl -pe "s{ ^ > \d+ \K \n }{\t}xms" 1.f +a > 1.txt c:\@Work\Perl\monks\yueli711>type 1.txt >1 AGTCGTAGCAT >2 TGAGCTACG >3 GGCATAGN >4 CGCACNCAGCTACACC >5 NGATAGCTACA
This runs under Windows. I can't test this, but I think if you're running under *nix, just replace all the  " (double-quotes) in the command-line with  ' (single-quotes).


Give a man a fish:  <%-{-{-{-<