如何交错来自两个文本文件的行 [英] How to interleave lines from two text files
本文介绍了如何交错来自两个文本文件的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
交错两个(或多个)文本文件的行的最简单/最快的方法是什么?示例:
What's the easiest/quickest way to interleave the lines of two (or more) text files? Example:
文件 1:
line1.1
line1.2
line1.3
文件 2:
line2.1
line2.2
line2.3
交错:
line1.1
line2.1
line1.2
line2.2
line1.3
line2.3
当然,编写一个打开它们并完成任务的小 Perl 脚本很容易.但我想知道是否有可能用更少的代码摆脱困境,也许是使用 Unix 工具的单行代码?
Sure it's easy to write a little Perl script that opens them both and does the task. But I was wondering if it's possible to get away with fewer code, maybe a one-liner using Unix tools?
推荐答案
paste -d '
' file1 file2
这篇关于如何交错来自两个文本文件的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文