bash - AWK, can't match regex -
i learnig awk, , trying match word file contain @ leas 2 vowels. code is
#!/usr/bin/awk -f begin{c=0} { for(i=1; i<=nf; i++){ if( match($i,"(.*[aeiou].*){2,}") > 0 ) c++ } } end{print c}
i using, test file, random stuff, like
asd e ef eseg <seg s<gko< <sg<se eg eg eg peaorj<ÈmofepriagÒajpd<skakropdsaf foeipsfipiè<+oèipiau aeiouaeiou
i tested regex on myregextester.com , there seems work. mistaking?
your awk script can refactored (or simplified) (gnu-awk):
awk -v rs='[[:space:]]+' '/(.*[aeiouaeiou].*){2}/{c++} end{print c+0}' file
it output:
4
because count words vowels have included upper case vowels character class.
-v rs='[[:space:]]+'
split input records of single word.
Comments
Post a Comment