How to make a file like:

one
two
three
...

into:

one one
two two 
three three
...

I'm thinking this must be possible with one simple Linux command. If my editor had block selections or macros I could do it easily. I'm using Geany right now. Maybe I need to switch editors again, or find a Geany plugin.

link|improve this question
I ended up installing SlickEdit (the original "E" editor) and recorded a macro to cut/paste the current line twice, skip to the next line, then hold down Ctrl+F12. If I don't end up buying SlickEdit, I'll keep an eye on these other answers for future reference, tnx. – ferodynamics Oct 20 '11 at 10:21
feedback

3 Answers

You need the paste command:

$ cat > file
one
two
three
four
...
$ paste file file
one     one
two     two
three   three
four    four
...     ...
$
link|improve this answer
feedback

In Bash, this reads from file.txt, and doubles every line, appending the output to out.txt

while read line; do echo "$line $line" >> out.txt; done < file.txt
link|improve this answer
feedback
$ cat t
ccc
ddd
aaa
bbb

$ perl -p -i -e 's/.*/$& $&/' t

$ cat t
ccc ccc
ddd ddd
aaa aaa
bbb bbb
link|improve this answer
I played with your answer a little bit, this seems to work too: sed 's/.*/& &/' t – ferodynamics Oct 20 '11 at 10:40
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.