How to count particular words using perl
When "grep -c" doesn't cut it (counts only 1 occurrence per line).
For example, to count the number of times ABCD appears in mysqldump output:
Modified version of snippet found in http://www.wellho.net/forum/Perl-Programming/Issue-with-Grep.html
perl -lne '$c++ while /SEARCH_STRING/g; END { print $c; }'
For example, to count the number of times ABCD appears in mysqldump output:
mysqldump my_db | perl -lne '$c++ while /ABCD/g; END { print $c; }'
Modified version of snippet found in http://www.wellho.net/forum/Perl-Programming/Issue-with-Grep.html