특정 문자를 포함하지 않는 연속 행 검색

특정 문자를 포함하지 않는 연속 행 검색

약간의 편집이 필요한 뉴스 기사가 있습니다. 기본적으로 문자 t와 h가 연속으로 두 번 이상 포함되지 않은 모든 줄을 검색하고 해당 줄에서 4글자 단어를 문자 D로 바꿔야 합니다. 어디서부터 시작해야할지 모르겠습니다. 예를 들어 다음과 같은 텍스트가 있습니다.

Animals are multicellular eukaryotic organisms which form a biological kingdom Animalia. 
Historically, Aristotle divided animals into those with blood and those without

나는 그것이 보이기를 원한다

Animals are multicellular eukaryotic organisms which D a biological kingdom Animalia.
Historically, Aristotle divided animals into those with blood and those without

답변1

파일 이름이 Myfile.txt인 경우 다음을 실행할 수 있습니다.

grep -Ev '[Tt][Tt]|[Hh][Hh]' Myfile.txt |  awk '{ gsub("([^[:alnum:]]|^)[[:alnum:]]{4}([[:space:]]|[[:punct:]])"," D ");print $0}' > MyEditedFile.txt

관련 정보