AWK count letters words

Hi All!

can anyone help me with this code?
I want to count words or letters in every line with

if(count>20){else echo $myline}
awk  '/<script /{p=1} /<\/script>/{p=0; next}!p' index.html |  while read myline; do
[count here if,else]
    echo $myline
done

Thank you !!!

Hi,

Try this one,

echo ${myline} | perl -ne '$t=$_;$c=$t=~s/[^ ]\s+[^ ]//g;print "Words:$c\nLetters:",length($_),"\n";'

Cheers,
Ranga:-)

1 Like

${#myline} will give you the length of myline.

wc can count letters, words, and lines.

Regards,
Alister

1 Like

Thank you
You're great!!!

I have one last question for the "if"
can you tell me where is the problem here?

awk  '/<script /{p=1} /<\/script>/{p=0; next}!p' index.html |  while read myline; do
counts=${#myline}
if ($counts>20) {  echo $myline }
else{}
done

Thank you guys!