Sed copy first string and append it to line

Advertisements

I have a file:

Text1 text2 50
Text3 text4 60

I would like to make the following using sed command:

Text1 Text1 text2 50
Text3 Text3 text4 60

I need to copy the first string and add it to the line.

>Solution :

sed 's/.* /&&/' input-file

Assumes a space as separator, and not a tab. & is shorthand for "entire match" when used on replacement side of s/// substitution

Leave a ReplyCancel reply