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:
Written by Marduk
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Linux
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#