Si votre fichier Input_file est identique à l'exemple illustré, le suivant peut également vous aider.
awk '{gsub(/ [0-9]+/,",&");gsub(/, /,",")} 1' Input_file
La sortie sera la suivante.
11111,22222,33333,44444 ,55555 ,66666
Explication de commande ci-dessus:
awk '{
gsub(/ [0-9]+/,",&"); ##gsub is awk utility to substitute things, so its format is gsub(regex_for_strings_to_be_replaced,with_whom_it_should_be_replaced,variable/line). So here I am substituting globally space then all digits(continuous ones) with a comma and (matched regex itself, which is space then all digits(continuous ones)).
gsub(/, /,",") ##Using gsub again here to replace comma then space(,) with only comma(,), to get the output into same shape in which OP has asked, it will remove space between command and digits which was created in above command.
}
1 ##awk works on method of condition then action, so here I am making condition as TRUE by mentioning 1 and not mentioning any action so be default print action will happen, print of current line.
' Input_file ##Mentioning Input_file name here.
juste penser à voix haute, mais essayez de remplacer les espaces par des virgules puis après remplacer '' ,, avec '' (espace) – Dominik
Voulez-vous vraiment un moins ' 3' et un de moins «4» dans la sortie? – jas
Merci pour votre réponse rapide. J'ai été capable de résoudre ce problème. puisque le champ où je devais insérer une virgule était constant, j'ai utilisé plusieurs commandes sed. donc pour l'exemple ci-dessus le cmd était – Aires69