find . -type f | xargs file | grep text | cut -d':' -f1 | xargs grep -l "TEXTSEARCH" {} it's a good solution? for find TEXTSEARCH recursively in only textual files
You can use the -r(recursive) and -I(ignore binary) options in grep:
$ grep -rI "TEXTSEARCH" .
-IProcess a binary file as if it did not contain matching data; this is equivalent to the--binary-files=without-matchoption.-rRead all files under each directory, recursively; this is equivalent to the-d recurseoption.
git grep so you can include checking uncommitted files and notes that this is much slower than git grep, just add -L. You'll note that including super-linter.log is slow, so add things like --exclude-dir='.[A-Za-z0-9]*' --exclude-dir=archive --exclude=super-linter.log. Then you're good to go.If you know what the file extension is that you want to search, then a very simple way to search all *.txt files from the current dir, recursively through all subdirs, case insensitive:
grep -ri --include=*.txt "sometext" * --include flag needs a glob pattern enclosed in quotes. This as it is won't work, more like this: --include="*.txt".Another, less elegant solution than kevs, is, to chain -exec commands in find together, without xargs and cut:
find . -type f -exec bash -c "file -bi {} | grep -q text" \; -exec grep TEXTSEARCH {} ";" -I