순서에 관계없이 최소한 모든 모음을 포함하지만 연속은 포함하지 않는 줄을 인쇄합니다.

순서에 관계없이 최소한 모든 모음을 포함하지만 연속은 포함하지 않는 줄을 인쇄합니다.

문제는 파일을 인수로 취하고 순서에 상관없이 적어도 모든 모음을 포함하는 모든 줄을 인쇄하지만 [두 개의 동일한 연속 모음이 없습니다.].

예를 들어 aeaiou는 허용되지만 'aa' 때문에 aaeiou는 허용되지 않습니다.

아래 스크립트는 거의 필요한 것이지만 연속성을 확인하지 않습니다.

egrep -i '.[a]+' ${1} | egrep -i '[e]+' | egrep -i '[i]+' | egrep -i '[o]+'| egrep -i '[u]+'

참고: grep 및 반복 구성을 사용할 수 있지만 모호하거나 상위 수준 명령은 사용할 수 없습니다.

해결됨;

egrep -vi '[a][a]' ${1} | egrep -vi '[e][e]' | egrep -vi '[i][i]' | egrep -vi '[o][o]' | egrep -vi '[i][i]' | egrep -i '[a]+' | egrep -i '[e]+' | egrep -i '[i]+' | egrep -i '[o]+'| egrep -i '[u]+'

답변1

이중 모음이 있는 경우 전체 줄을 제외하려는 경우 다음과 같이 작동합니다.

grep -i a file | \
    grep -i e | \
    grep -i i | \
    grep -i o | \
    grep -i u | \
    grep -v -i '\([aeiou]\)\1'

답변2

여러 번 호출하는 대신 grep단일 호출을 사용할 수도 있습니다 sed.

sed -rn '/(aa|ee|ii|oo|uu)/d; /a/{/e/{/i/{/o/{/u/p}}}}'

또는

sed -rn '/([aeiou])\1/d; /a/{/e/{/i/{/o/{/u/p}}}}'

역참조를 사용하려는 경우.

답변3

질문(약간 수정, 앞에 줄 바꿈 포함 but not aaeiou because of the 'aa')을 입력으로 사용:

$ cat hehe.txt
The problem is to write a script that takes a file as argument
and prints all the lines that contain -at least- all the vowels ,
-regardless of ordering-, but with [no two same consecutive vowels].

e.g aeaiou is allowed, 
but not aaeiou because of the 'aa'

The script below is almost what I need, but it does not check for
consecutiveness.

$ awk 'BEGIN { IGNORECASE=1 };
       ! /aa|ee|ii|oo|uu/ && ( /a/ && /e/ && /i/ && /o/ && /u/ )' hehe.txt
The problem is to write a script that takes a file as argument
-regardless of ordering-, but with [no two same consecutive vowels].
e.g aeaiou is allowed, 

스크립트 awk는 대소문자 구분 모드를 활성화하고 이중 모음이 포함된 줄을 제거한 다음 각 모음이 하나 이상 포함된 줄을 인쇄합니다.

관련 정보