Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    As a note, this will also cause grep to match file names that match your pattern. Commented May 21, 2013 at 9:21
  • Yes, I know. Unless one uses particularly weird file names, one can fix that by strings --print-file-name * | grep ': message' (the file names output by strings are terminated by : ). The main question is whether the OP wants just the file names (then using grep -l only is better), or whether he also wants the matched strings (then grep will either complain about binary garbage, or output binary garbage, and none of these is helpful). Commented May 21, 2013 at 9:31
  • Correction: If the pattern "message" can occur anywhere in the string, strings --print-file-name * | grep ': .*message' is better. Commented May 21, 2013 at 9:44
  • (assuming there's no file named foo: message for instance) Commented May 21, 2013 at 10:25
  • That was one of the two things I meant when I talked about "particularly weird file names". (The other one is newlines in file names.) Commented May 21, 2013 at 10:30