10

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
7

Sed:

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

Awk:

awk 'BEGIN { OFS = "\n" } { $1=$1; print }' input.txt > output.txt
| improve this answer | |
23

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

| improve this answer | |
  • 1
    Easiest and fastest, too. – JRFerguson Oct 2 '12 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. – J. M. Becker Nov 1 '12 at 14:50
0

With printf :

printf '%s\n' $(<FILE)
| improve this answer | |
  • I wonder why this was down-voted. – Gilles Quenot Oct 2 '12 at 22:41
  • Possibly because this will split on spaces not just tabs. – jordanm Oct 3 '12 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.