Reputation: 4328
I need to format a mailing list, by adding a comma at the end of every line. This question has been already asked, however I don't get the expected result with the suggested answer:
sed '$!s/$/,/' file > out.txt
results in:
[email protected]
,
[email protected]
,
[email protected]
. . .
Is there anyway it can be improved ? I'd need rather need:
[email protected],
[email protected],
[email protected],
. . .
Thanks!
Upvotes: 7
Views: 12408
Reputation: 92854
Use the following approach to add comma at the end of each line:
sed 's/$/,/' file > out.txt
s/regexp/replacement/flags
Upvotes: 10