The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 08-13-2008
Pep Puigvert Pep Puigvert is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 3
Lightbulb counting a list of string in a list of txt files

Hi there!

I have 150 txt files named chunk1, chunk2, ........., chunk150. I have a second file called string.txt with more than 1000 unique strings, house, dog, cat ... I want to know which command I should use to count how many times each string appears in the 150 files.

I have tried with a grep -c dog chunk* but then I get the count of all of the files and I have to do it separately for each of the strings.

The ideal solution would be an output saying:

dog 45
cat 69
house 92
song 45

Thanks a lot in advance.

Kind regards,
Pep