11

input.txt (around 30K lines)

RT|367079254|bn|ERTS01065811.1| 38 1 503
RT|367079251|bn|ERTS01065814.1| 56 3 502
RT|367079248|bn|ERTS01065817.1| 52 2 502

output.txt

RT|367079254|bn|ERTS01065811.1|
38
1
503
RT|367079251|bn|ERTS01065814.1|
56
3
502
RT|367079248|bn|ERTS01065817.1|
52
2
502

3 Answers 3

26

I think your easiest way to do this is with tr:

tr '\t' '\n' < input.txt > output.txt

That'll turn all the tabs to newlines.

tr - Man Page

2
  • 1
    Easiest and fastest, too.
    – JRFerguson
    Oct 2, 2012 at 22:58
  • 1
    You should have been awarded this answer, as tr was the best solution. Both sed, and awk, while great tools, are overkill. Nov 1, 2012 at 14:50
8

Sed:

sed -e 'y/\t/\n/' input.txt > output.txt

Awk:

awk 'BEGIN { OFS = "\n" } { $1=$1; print }' input.txt > output.txt
0

With printf :

printf '%s\n' $(<FILE)
2
  • I wonder why this was down-voted. Oct 2, 2012 at 22:41
  • Possibly because this will split on spaces not just tabs.
    – jordanm
    Oct 3, 2012 at 3:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.