Pregunta

File1:

hello      world
foo   bar
a  word with a space

Necesito reemplazar todos los espacios en blanco que tienen una longitud de dos o más con un punto y coma (;).

Resultado:

File2:

hello;world
foo;bar
a;word with a space
¿Fue útil?

Solución

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

Otros consejos

$ 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

Prueba:

sed -e 's/  */;/g' file
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top