I have a file like this
{CRLF
sum: 21.46,CRLF
first: 99.10,CRLF
last: 57.71 CRLF
}CRLF
{CRLF
sum: 159.32,CRLF
first: 456.71,CRLF
last: 89.27 CRLF
}CRLF
...
ps. CRLF is the line break in windows system, not really text in this file.
I want to add a comma at the end of every line containing "last:".
I used the following command
sed '/last/ s/$/,/' old.txt >new.txt
but I got a weird result
{CRLF
sum: 21.46,CRLF
first: 99.10,CRLF
last: 57.71 CR
,CRLF
}CRLF
{CRLF
sum: 159.32,CRLF
first: 456.71,CRLF
last: 89.27 CR
,CRLF
}CRLF
...
The comma doesn't append at the end of line. Instead, it append at a new line. Any idea will be greatly appreciated. Thanks.