Question

Fichier1:

hello      world
foo   bar
a  word with a space

Je dois remplacer tous les espaces blancs de deux ou plus par un point-virgule (;).

Résultat:

Fichier2:

hello;world
foo;bar
a;word with a space
Était-ce utile?

La solution

sed -e 's/  \+/;/g' File1 > File2

Autres conseils

$ gawk 'BEGIN{FS="  +"}{$1=$1}1' OFS=";" file
hello;world
foo;bar
a;word with a space

$ awk '{gsub(/  +/,";")}1' file
hello;world
foo;bar
a;word with a space

Essayez:

sed -e 's/  */;/g' file
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top