Last Updated: February 25, 2016
·
351
· netors

Get a list of files that contain a string in a directory and subdirectory then sort by count

Sometimes I need to search a {string} inside the source code of a project, I need to know where this {string} is found.., actually I want to count how many times it is found in the whole project, and then sort the list of results by the number of times the {string} was found.

grep -c -R {string} * | sed '/:0$/d' | sort -k2n -t: