質問
File1:
hello world
foo bar
a word with a space
長さが2つ以上のすべての空白をセミコロン(;)に置き換える必要があります。
結果:
File2:
hello;world
foo;bar
a;word with a space
解決
sed -e 's/ \+/;/g' File1 > File2
他のヒント
$ 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
試してください:
sed -e 's/ */;/g' file
所属していません StackOverflow