How to replace space with comma using sed?
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.
If you are talking about sed
, this works:
sed -e "s/ /,/g" < a.txt
In vim
, use same regex to replace:
s/ /,/g