How to replace space with comma using sed?

前端 未结 8 839
-上瘾入骨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 22:57

    Inside vim, you want to type when in normal (command) mode:

    :%s/ /,/g
    

    On the terminal prompt, you can use sed to perform this on a file:

    sed -i 's/\ /,/g' input_file
    

    Note: the -i option to sed means "in-place edit", as in that it will modify the input file.

提交回复
热议问题