-2

I would like to recursively traverse a directory tree and extract all files which contain a certain text in a remote Linux machine. I found a helpful command in this website:

grep -iRl "your-text-to-find" ./

Now however, I would like to modify this slightly by searching only in python (.py) files. I tried the following but it doesn't seem to work:

grep -iRl "your-text-to-find" ./*.py

How can I modify the command such that it recursively finds all .py files containing "your-text-to-find?

user32882
  • 5,094
  • 5
  • 43
  • 82

1 Answers1

0

After looking through a few extra posts including this one, I found a command which works.

I am not exactly sure what xargs does but the post I mentioned explains a bit more:

 find ./ -name *.py | xargs grep "text-to-find"
user32882
  • 5,094
  • 5
  • 43
  • 82