Skip directly to content

erantone's blog


on Thu, 01/21/2016 - 12:58
This is a list of external links which could be useful.


Counting the number of occurrences of a string in a file

on Fri, 07/18/2014 - 15:32
Let's assume you want to find the number of ocurrences of a string in a big XML file, quickly.
Let the filename be 'properties.xml', the keyword string be '<property>', and the script language be Perl. Then, the following command will print the total number of occurrences: 
perl -lnwe '$a+=()=/\Q<property>/g; }{ print $a;'  properties.xml