0

I'm trying to recursively look for C Sharp files containing specific text using a bash prompt on Windows Subsystem for Linux.

If I type grep -l -i -r "public virtual List<" /mnt/c/mycode/* it works.

However, I'd like to just search the C Sharp files

If I type grep -l -i -r "public virtual List<" /mnt/c/mycode/*.cs I see:

grep: /mnt/c/Workspaces/locumsmart/*.cs: No such file or directory

Is there a way to just search for a particular file extension?

Eric
  • 1,203
  • 4
  • 20
  • 35
  • For many years the duplicate question had only answers giving solutions, but not (or badly) explaining why or what was wrong. And also here you got an answer that is not bad, but not educative either. Few months ago I added [this answer](https://superuser.com/a/1773677/432690). If you want to understand why your command failed and why the answer you accepted worked, read my answer. Note your Bash in Windows Subsystem for Linux should behave like Bash in a standalone Linux, so the part named "Nuances of Windows" does not apply. – Kamil Maciorowski May 26 '23 at 19:31

1 Answers1

1

Use --include=\*.cs

grep -l -i -r --include=\*.cs "public virtual List<" /mnt/c/mycode/*
L. Scott Johnson
  • 126
  • 1
  • 2
  • 7