This question came from our site for professional and enthusiast programmers.

Note also that grep -c does not give you the number of occurrences... It gives you the number of lines that match. So if you have a line that says "stringstring", that will count as 1, not 2.
–
asveikauApr 29 '10 at 21:51

The first grep in the backticks searches for matching files, listing only the names. The first ls then sorts those by modification time in reverse. We then search through each file a second time to count occurrences, and prepend the count to the standard "ls -l" listing.

This will be slow; if you really need a faster version you can probably hack one up in a scripting language.