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.
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.
Copyright © 2021 Jogjafile Inc.
Assumes a space as separator, and not a tab.
&is shorthand for "entire match" when used on replacement side ofs///substitutionNote that prior answer
s/.* /&&/above only works for 2-word inputs. It's too greedy. So we're matching one or more non-space characters followed by a space.