I often need to search for a particular string from a directory that has git directory .git/. This is the command I use:
find . -name .git -prune -o -print | xargs grep <string-to-search>
The -name .git -prune -o -print option is to ignore the files under .git/. However, it outputs a lot of 'Is a directory' messages that clutter the whole result. For example,
...
grep: ./reports: Is a directory
grep: ./scripts: Is a directory
grep: ./scripts/js: Is a directory
grep: ./scripts/js/adapter: Is a directory
...
How to modify the command line so that I can ignore the .git/ directory and all other directories (i.e. only search the searchable files).
Apparently, the -type f option doesn't work well in:
find -type f . -name .git -prune -o -print