I use a txt file, and I need to convert it in csv fileSaint Petersburg      0     10    0.1   -   NMoscow                -     9       0   -   NNovgorod              0     7       1   30  YIn bash, how can I insert comma after the last letter, and after every number or -For example Saint Petersburg,      0,     10,    0.1,   -,  NMoscow,                -,     9,       0,   -,  NNovgorod,              0,     7,       1,   30, YBest
insert comma after the last letter
text processing;csv
This will replace sequences of 2 or more spaces by a command and the same spaces less one:sed 's/ \( \+\)/,\1/g' file.txtIt will fail if there is only one space between columns.If you only want ,  as the field separator:sed 's/ \{2,\}/, /g' file