2

I would use the following command to grep a text in a directory with many files.

grep -irl "SampleText" *.txt

My case is to grep only in .txt files. While executing the above command in command prompt of windows it throws an error like

grep: *.txt: Invalid argument

Did I miss something?

2 Answers 2

7

Use:

grep --include=*.txt -irl . -e "SampleText"

remove the l argument to print the text and it's surrounding text too
and add the n argument to see the line number of the text you found

Use man grep for further info

1

Use the built-in utility?

findstr /s /i /m "SampleText" *.txt

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