我想使用sed复制输入的每一行。即当输入看起来像:
first
secod
third
fourth
...
我希望输出看起来像:
first first
second second
third third
fourth fourth
... ...
等等。
如果使用sed不可能,那么你推荐什么?我更喜欢最简单的解决方案。
答案 0 :(得分:4)
这似乎是paste
命令的定制作业:
paste -d " " file file
答案 1 :(得分:3)
一种方式:
$ sed 's/.*/& &/' file
first first
second second
third third
fourth fourth
答案 2 :(得分:2)
使用awk,
awk '{print $1, $1}' file
或作为评论,如果单词包含空格,则可以执行以下操作:
awk '{print $0, $0}' file