How to replace space with comma using sed?

前端 未结 8 850
-上瘾入骨i
-上瘾入骨i 2020-12-30 22:52

I would like to replace the empty space between each and every field with comma delimiter.Could someone let me know how can I do this.I tried the below command but it doesn\

8条回答
  •  清歌不尽
    2020-12-30 23:20

    If you want the output on terminal then,

    $sed 's/ /,/g' filename.txt
    

    But if you want to edit the file itself i.e. if you want to replace space with the comma in the file then,

    $sed -i 's/ /,/g' filename.txt
    

提交回复
热议问题