How would you count every occurrence of a term in all files in the current directory? – and subdirectories(?)
I've read that to do this you would use grep
; what is the exact command?
Also, is it possible to the above with some other command?
command linedirectoryfilesgrep
How would you count every occurrence of a term in all files in the current directory? – and subdirectories(?)
I've read that to do this you would use grep
; what is the exact command?
Also, is it possible to the above with some other command?
Best Answer
Using
grep
+wc
(this will cater for multiple occurences of the term on the same line):-r
ingrep
: searches recursively in the current directory hierarchy;-F
ingrep
: matches against a fixed string instead of against a pattern;-o
ingrep
: prints only matches;-l
inwc
: prints the count of the lines;