I have a large set of files in a directory. The files contains arbitrary text.
I want to search for the file name inside that particular file text. To clarify, I have
file1.py.txt (yeas, two dots
file2.py.txt both contains texts. I want to search for the existence of the string
@code prefix.file1.py inside
file1.py.txt and for the string
@code prefix.file2.py inside
How can I customize
grep such that it goes through every file in the directory, search for the string in each file using that particular file name?
The output I am looking for is written in a separate file,
result.txt which contains:
filename (if a match is found), the line text (where the match is found)