Domanda

File1:

hello      world
foo   bar
a  word with a space

Devo sostituire tutti gli spazi bianchi che sono due o più di lunghezza con un punto e virgola (;).

Risultato:

File2:

hello;world
foo;bar
a;word with a space
È stato utile?

Soluzione

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

Altri suggerimenti

$ 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

Prova:

sed -e 's/  */;/g' file
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top