# perl -le'$cnt+=@{[m/\bhello\b/g]}for"aahello hello hello","bb heelo hello phello";print$cnt' 3 #### # perl -nle'$cnt+=@{[m/\bhello\b/g]}}END{print$cnt' file