Linux command to count number of occurrences of a string in a specific file type within the whole dir -
i used following cmd count lines of class appears within h extension files
grep -rc 'class' --include \*.h mydirc|wc -l
however, think result wrong when add number of occurrence each file, it's wrong. found wc -l counting number of files searched , printed on screen. exmaple,
/afs/eos/dist/ds5-2013.06/fastmodelstools_8.2/osci/syst...sc_buffer.h:6
i added number of h: up, didn't match final value. final value matches number of printed lines on sreen same number of .h extension files has searched.
how about
find . -name \*.h | xargs grep class | wc -l
Comments
Post a Comment