My best shot so far (for finding strings in a directory containing a large C program)
find ~/example_directory -type f \( -name "*.mk" -or -name "*.[sch]" \) -print0 | xargs -0 -e grep "example_string"
Which works very well, but it relies on all the interesting things found in the .mk makefiles, .c or .h source files and .s assembly files.
I was thinking of adding things like “all files called Makefile” or “all * .py python scripts”, but the question is, what would be easier if you could find find, to find only text files.
If you just run grep for all files, it takes a long time, and you get a lot of uninteresting calls to object files.
source share