合并 x 和 x + n 行

合并 x 和 x + n 行

我正在编写一个脚本,它返回 15 行标题和 15 行 URL。

title 1
title 2
title 3
*snip*
title 14
title 15
http://example.com/query?1
http://example.com/query?2
http://example.com/query?3
*snip*
http://example.com/query?14
http://example.com/query?15

我想以产生以下输出的方式合并它:

title 1 http://example.com/query?1
title 2 http://example.com/query?2
title 3 http://example.com/query?3
*snip*
title 15 http://example.com/query?15

经过灯光检查和指导这个答案,我找到了命令paste。但是,paste不允许执行如上所述的更复杂的行为。我可以使用其他工具或工具组合来完成上述行为吗?

请注意,如果可能的话,我希望使用所有标准 coreutils 行为。

答案1

您正在寻找pr命令

pr -2t -s" " file

相关内容