jazz
1
I have a file which contains numbers as follows:
1234 9876 6789 5677 3452
9087 4562 1367 2678 7891
I need to remove the empty spaces and add commas between the numbers like:
1234,9876,6789,5677,3452,
9087,4562,1367,2678,7891
Can anyone tell me the command to do the same?
Thankx
mona
2
$ cat sample
1234 9876 6789 5677 3452
9087 4562 1367 2678 7891
$ sed 's/\( \)\{1,\}/,/g' sample
1234,9876,6789,5677,3452,
9087,4562,1367,2678,7891
$
or
$ sed 's/ \+/,/g' sample
1234,9876,6789,5677,3452,
9087,4562,1367,2678,7891
HTH,
Mona
system
4
cat filename | tr -s " " ","
Note: In the first quotes, there is space