I want to duplicate each line of the input using sed. Ie 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.
这似乎是paste
命令的定制工作:
paste -d " " file file
One way:
$ sed 's/.*/& &/' file
first first
second second
third third
fourth fourth
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.