How can I use sed to copy before comma and paste after slash in a file?
Example:
text1,Information /
text2,Information /
text3,Information /
and I want
text1,Information /text1
text2,Information /text2
text3,Information /text3
CodePudding user response:
This works with your example:
sed -r 's@(.*),(.*)/@\1,\2/\1@' <file_path>
The idea is that groups (between parentheses) are referenced in the substitution part.
CodePudding user response:
This might work for you (GNU sed):
sed -E 's/([^,]*).*/&\1/' file
Capture everything before the ,
and append to the end of the line.