0

How may I use grep (or any other tool) to search one string per file only once and also print that file name?

0
2
grep -rFl "string" /path/
  • -r: search recursively (not standard but pretty common)
  • -F: fixed string search (as opposed to regexp pattern matching)
  • -l: List name of the file containing "string"

You can also use:

find /path -type f -exec  grep -lF "string" {} +

If your grep doesn't support -r.

1
  • 1
    @Kusalananda, sorry, I just edited the recommendations at that Q&A in. Sourav, I'd suggest you read it. – Stéphane Chazelas Jun 28 '17 at 20:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.