How to replace space with comma using sed?

sed replace multiple spaces with comma
sed replace string with space
sed replace space with newline
sed replace newline with comma
python replace space with comma in a file
sed replace with blank space
sed replace slash with space
replace space with comma python

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't work.thanks.

My command:
:%s//,/


53 51097 310780 1
56 260 1925 1
68 51282 278770 1
77 46903 281485 1
82 475 2600 1
84 433 3395 1
96 212 1545 1
163 373819 1006375 1
204 36917 117195 1

If you are talking about sed, this works:

sed -e "s/ /,/g" < a.txt

In vim, use same regex to replace:

s/ /,/g

Replace all white spaces with commas in a text file, With sed : sed -e 's/\s\+/,/g' orig.txt > modified.txt. Or with perl : perl -pne 's/\s+/,/g' < orig.txt > modified.txt. Edit: To exclude newlines in perl you could use a  IF your data includes an arbitrary sequence of blank characters (tab, space), and you want to replace each sequence with one comma, use the following: sed 's/[\t ]+/,/g' input_file or

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.

SED command to replace whitespace with comma, I need to remove the whitespace in between the text and replace it with a comma. 1,2,3,4 11,22,33,44. Can someone explain how I can achieve this? I need to replace all white spaces inside my text with commas. I'm currently using this line but it doesn't work: I get as output a text file which is exactly the same of the original one: sed 's/[:blank:]+/,/g' orig.txt > modified.txt thanks

I know it's not exactly what you're asking, but, for replacing a comma with a newline, this works great:

tr , '\n' < file

How to match whitespace in sed?, Which command will translate all the white space to tabs? I want to replace every comma not enclosed in a pair of double quotes with '|' using awk pattern matching within sed. For example, given the following input: A,B,"C,D

Try the following command and it should work out for you.

sed "s/\s/,/g" orignalFive.csv > editedFinal.csv

Replace whitespaces with tabs in linux, SHELL SCRIPT Hi I have a file in the following format Mayank Sushant Dheeraj Kunal ARUN Samir How can i replace the white space in between and replace  $ cat texte-new.txt this,is,a,text in,which,I,want,to,replace spaces,by,commas I wouldn't go just replacing the old file by the new one (could be done with sed -i, if I remember correctly ; and as @ghostdog74 said, this one would accept creating the backup on the fly) : keeping might be wise, as a security measure (even if it means having to

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

How to Use Sed Command to replace white spaces with comma , If you use double quotes, bash interprets \\ and outputs \ which is then again interpreted from sed together with the following space to just the  Replacing / with TAB using sed. Replace whitespace with a comma in a text file in Linux. 680. How to do a recursive find/replace of a string with awk or sed? 5.

command line, Use sed -e "s/[[:space:]]\+/ /g". Here's an explanation: [ # start of character class [:​space:] # The POSIX character class for whitespace characters. It's # functionally​  I would like to replace blank spaces/white spaces in a string with commas. STR1=This is a string to STR1=This,is,a,string

sed replace all tabs and spaces with a single space, Re: replace commas in a macro variable and put spaces Posted 05-10-2017 (​15884 Text Replacer. punctuation constant. sed -e 's/ /\t/g' test. To change pluses to spaces only when they are flanked by words: sed 's/\>+\</ /g' This would change a+b to a b but would leave a + b and a++b unmodified.. The pattern \> matches the zero width space at the end of a word, and \< is analogous for the start of a word.

Replace whitespace with comma online, sed: Replace spaces with commas. spaces.sh. sed -e 's/^[ ][ ]*//g' -e 's/[ ][ ]*/,/g'. Comment on gist. Sign in to comment or sign up to join this conversation on 

Comments
  • Is this VIM? I don't see sed anywhere.
  • Yea it's inside vim editor.
  • It does look like he's trying to use Vim here, not sed, good call
  • If you are on Max OSX the -i option requires an argument. You can pass it an empty string if you don't desire a backup.
  • ^ thank you so much, spent a while trying to fix this command on a mac
  • Nice one, I was looking for this specifically, thanks