0

I want to know which files in a folder contain a certain string. There are many answers on here showing how to grep through many files. However, is there a way to print out the file names that have the string present?

I want to use something like:

grep -E '275322' *.txt

Can I use echo to print the file currently being looked at if the string is present?

Any help is appreciated.

1 Answers1

1

If I understand the question correctly, you only want the filenames?

grep -l '275322' *

Check the manpage -

  -l, --files-with-matches  print only names of FILEs containing matches
Paul Hodges
  • 13,382
  • 1
  • 17
  • 36