Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: change \n to \t

by AnomalousMonk (Bishop)
on Aug 23, 2019 at 16:41 UTC ( #11104909=note: print w/replies, xml ) Need Help??

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:  <%-{-{-{-<

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11104909]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2021-01-21 23:39 GMT
Find Nodes?
    Voting Booth?