텍스트 파일 내의 두 개 이상의 공간을 a로 교체하십시오.

StackOverflow https://stackoverflow.com/questions/1616638

  •  06-07-2019
  •  | 
  •  

문제

파일 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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top