I was doing a little script to find and count all "the" appearences in numerous files and subdirectories, then i need to print the file address and the number of "the" appearances. But I don't know how to finish it.
find . -name "*.txt" -type f -printf "%p\t" -exec grep -c "the" {}\;
ex.sh the name of the program
txt a file extension
the a word to find the appearences
The correct output should be:
./ex.sh txt the ./etext00/00ws110.txt 42764 ./etext00/1cahe10.txt 26692 ./etext00/1vkip11.txt 21895 ./etext00/2cahe10.txt 24604 ./etext00/2yb4m10.txt 15476 ./etext00/8rbaa10.txt 3131
What i get:
./etext00/00ws110.txt 35388 ./etext00/1cahe10.txt 17905 ./etext00/1vkip11.txt 14617 ./etext00/2cahe10.txt 16971 ./etext00/2yb4m10.txt 9938 ./etext00/8rbaa10.txt 1839
Which I assume it's the number of lines containing a "the" appearance but in some lines there can be more than 1 "the".