转换制表符分隔的文件以使用换行符


10

input.txt(大约3万行)

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

Answers:


7

Sed

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

Awk

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

23

我认为您最简单的方法是tr

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

这样会将所有选项卡都换行。

tr-手册页


1
也最简单,最快。
JRFerguson 2012年

1
您应该被授予此答案,这tr是最好的解决方案。无论sedawk,而强大的工具,是矫枉过正。
JM Becker

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.