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


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?



sed -e '1h;G;s/\n/ /' <file
| improve this answer | |
  • @user3576105 If this answer solved your issue, please take a moment and accept it by clicking on the check mark to the left. That will mark the question as answered and is the way thanks are expressed on the Stack Exchange sites. – terdon May 26 '16 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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