Linux - How do I search all non-binary (text) files recursively for a certain string

  • search all files for a string
  • skip binary
  • recursively
  • list filenames
  • (and if possible echo the line + line number of the filename where it was found as option)

I was looking at Bash: passing braces as arguments to bash function and How to search for a string only in textfiles? (recursively)

But did not find an answer, only discussion

1 Answer 1


With GNU grep, adding the following options:

  • -F or --fixed-strings
  • -I or --binary-files=without-match
  • -r or --recursive
  • this is the default when using -r, but may be made explicit with -H or --with-filename
  • -n or --line-number


grep -FIrn string .

See man grep.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .