Search code examples
unixword-countwc

Unix command to count a given string and print with filename


i have a multiple files in a folder. i want to read the files to count a word present and print with filename.

for example: numeric value is matching count of the string

filename string1 string2
file1      5       1
file2      3        7

Solution

  • find . -name "ABC" -exec grep -H 'XYZ' {} +

    reference link