Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: change \n to \t

by AnomalousMonk (Archbishop)
on Aug 23, 2019 at 16:41 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 22:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found