텍스트 파일 내의 두 개 이상의 공간을 a로 교체하십시오.
문제
파일 1 :
hello world
foo bar
a word with a space
길이가 둘 이상인 모든 흰색 공간을 세미콜론 (;)으로 교체해야합니다.
결과:
파일 2 :
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