I have a file with the following data:
1 abcd hello world 5000
(note: there are 15 spaces between each word and "hello world" is a single entry with one space in between)
I have to replace the 15 spaces with a single comma(,). the single space between "hello and "world" should remain as it is.
I have tried various combinations of sed and tr command but nothing is working.
This is a job for
sed
:or, without the
-r
flag that allows extended regexp:This says: get 15 spaces and replace them with a comma. Smaller amount of spaces won't be replaced.