# perl -nle'$cnt+=@{[m/\bhello\b/g]}}END{print$cnt' file