Pergunta

File1:

hello      world
foo   bar
a  word with a space

I necessário substituir todos os espaços em branco que são duas ou mais de comprimento, com um ponto e vírgula (;)

.

Resultado:

File2:

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

Solução

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

Outras dicas

$ 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

Tente:

sed -e 's/  */;/g' file
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top