Reputation: 17
I am trying to do a search and replace on a string, doing a backward search on the pattern in shell script.
I have tried with the below, but it is not working for me
sed -r 's/ $/,/'
I am trying to apply this search and replace on a file having content like below
0 1 2 Comp level
I want the third space to be replaced with a comma
output should be like
0 1 2,Comp level
Upvotes: 0
Views: 417
Reputation: 88583
To replace third space by ,
:
echo '0 1 2 Comp level' | sed 's/ /,/3'
Output:
0 1 2,Comp level
Upvotes: 1