How can I add a comma at the end of every line except the last line?

前端 未结 4 1744
星月不相逢
星月不相逢 2020-12-07 22:36

I want add a comma at the end of every line of this kind of file except the last line:

I have this now:

{...}
{...}
{...}
{...}

I w

4条回答
  •  庸人自扰
    2020-12-07 23:39

    You can use something like this:

     sed 's/$/,/' file.txt > file_with_added_commas.txt
    

    This will substitute the end of the line with a ',' and write it to file_with_added_commas.txt

    For more information refer to: add text at the end of each line

提交回复
热议问题