Frage

File1:

hello      world
foo   bar
a  word with a space

Ich brauche alle weißen Flächen zu ersetzen, die mit einem Semikolon zwei oder mehr in der Länge sind (;).

Ergebnis:

File2:

hello;world
foo;bar
a;word with a space
War es hilfreich?

Lösung

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

Andere Tipps

$ 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

Versuchen:

sed -e 's/  */;/g' file
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top