How to append the first line at the end of each line of a file with Sed

sedtext processing

I'm trying to append the first line of a file at the end of each line with a single sed command:

Example:

line 1
line 2
line 3
line 4

should become:

line 1 line 1
line 2 line 1
line 3 line 1
line 4 line 1

How can I do it?

Best Answer

Simply:

sed -e '1h;G;s/\n/ /' <file