Reputation: 1057
I want to duplicate each line of the input using sed. I.e. when the input looks like:
first
secod
third
fourth
...
I want the output to look like:
first first
second second
third third
fourth fourth
... ...
and so on.
If this is impossible using sed, then what do you recommend? I prefer the most simple solution.
Upvotes: 2
Views: 2235
Reputation: 785561
This appears to be tailor-made job for paste
command:
paste -d " " file file
Upvotes: 4
Reputation: 85845
One way:
$ sed 's/.*/& &/' file
first first
second second
third third
fourth fourth
Upvotes: 6
Reputation: 11479
Use awk,
awk '{print $1, $1}' file
or as commented, you can do the following in case the words contain white spaces:
awk '{print $0, $0}' file
Upvotes: 2