search through all *.py files [duplicate]

Clash Royale CLAN TAG#URR8PPP
This question already has an answer here:
How to list .txt files with specific content?
4 answers
I am using Mac OS terminal (similar to Linux) and trying to find best way to search inside all files on a computer that has extension *.py
What is the best way to achieve this?
I wanted to put 1 keyword for search and quickly show the whole path of these python files are that contain requested keyword in them..
command-line grep find osx python
marked as duplicate by Mikel, muru, Jeff Schaller, schily, RalfFriedl Dec 11 at 18:23
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
How to list .txt files with specific content?
4 answers
I am using Mac OS terminal (similar to Linux) and trying to find best way to search inside all files on a computer that has extension *.py
What is the best way to achieve this?
I wanted to put 1 keyword for search and quickly show the whole path of these python files are that contain requested keyword in them..
command-line grep find osx python
marked as duplicate by Mikel, muru, Jeff Schaller, schily, RalfFriedl Dec 11 at 18:23
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
How to list .txt files with specific content?
4 answers
I am using Mac OS terminal (similar to Linux) and trying to find best way to search inside all files on a computer that has extension *.py
What is the best way to achieve this?
I wanted to put 1 keyword for search and quickly show the whole path of these python files are that contain requested keyword in them..
command-line grep find osx python
This question already has an answer here:
How to list .txt files with specific content?
4 answers
I am using Mac OS terminal (similar to Linux) and trying to find best way to search inside all files on a computer that has extension *.py
What is the best way to achieve this?
I wanted to put 1 keyword for search and quickly show the whole path of these python files are that contain requested keyword in them..
This question already has an answer here:
How to list .txt files with specific content?
4 answers
command-line grep find osx python
command-line grep find osx python
edited Dec 11 at 18:36
Rui F Ribeiro
38.8k1479128
38.8k1479128
asked Dec 11 at 15:28
Joe
1062
1062
marked as duplicate by Mikel, muru, Jeff Schaller, schily, RalfFriedl Dec 11 at 18:23
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Mikel, muru, Jeff Schaller, schily, RalfFriedl Dec 11 at 18:23
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Try this,
find / -name '*.py' -exec grep -l "keyword" ;
Explanation:
find / -name '*.py': Find files below/withpyextension.-exec grep -l keyword ;Within the files found,grepfor keyword and output the filename instead of the match-l.
I'm not familiar with Mac OS, but if you have globstar option in your shell, you can use the following:
shopt -s globstar
grep -l keyword /**/*.py
I think mac hasbashshell (same as Gnu/Linux), but by default not all gnu tools (some are bsd). Yourfindfinds files ending.py(there is no such thing as file-name-extensions, on Unix).
– ctrl-alt-delor
Dec 11 at 15:54
add a comment |
To look for the string needle in a bunch of Python files in a haystack directory:
$ grep -l 'needle' haystack/*.py
To descend into a directory tree, you could either use grep -R or switch to iterating via find as in the answer from RoVo.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try this,
find / -name '*.py' -exec grep -l "keyword" ;
Explanation:
find / -name '*.py': Find files below/withpyextension.-exec grep -l keyword ;Within the files found,grepfor keyword and output the filename instead of the match-l.
I'm not familiar with Mac OS, but if you have globstar option in your shell, you can use the following:
shopt -s globstar
grep -l keyword /**/*.py
I think mac hasbashshell (same as Gnu/Linux), but by default not all gnu tools (some are bsd). Yourfindfinds files ending.py(there is no such thing as file-name-extensions, on Unix).
– ctrl-alt-delor
Dec 11 at 15:54
add a comment |
Try this,
find / -name '*.py' -exec grep -l "keyword" ;
Explanation:
find / -name '*.py': Find files below/withpyextension.-exec grep -l keyword ;Within the files found,grepfor keyword and output the filename instead of the match-l.
I'm not familiar with Mac OS, but if you have globstar option in your shell, you can use the following:
shopt -s globstar
grep -l keyword /**/*.py
I think mac hasbashshell (same as Gnu/Linux), but by default not all gnu tools (some are bsd). Yourfindfinds files ending.py(there is no such thing as file-name-extensions, on Unix).
– ctrl-alt-delor
Dec 11 at 15:54
add a comment |
Try this,
find / -name '*.py' -exec grep -l "keyword" ;
Explanation:
find / -name '*.py': Find files below/withpyextension.-exec grep -l keyword ;Within the files found,grepfor keyword and output the filename instead of the match-l.
I'm not familiar with Mac OS, but if you have globstar option in your shell, you can use the following:
shopt -s globstar
grep -l keyword /**/*.py
Try this,
find / -name '*.py' -exec grep -l "keyword" ;
Explanation:
find / -name '*.py': Find files below/withpyextension.-exec grep -l keyword ;Within the files found,grepfor keyword and output the filename instead of the match-l.
I'm not familiar with Mac OS, but if you have globstar option in your shell, you can use the following:
shopt -s globstar
grep -l keyword /**/*.py
edited Dec 11 at 15:37
answered Dec 11 at 15:32
RoVo
2,558215
2,558215
I think mac hasbashshell (same as Gnu/Linux), but by default not all gnu tools (some are bsd). Yourfindfinds files ending.py(there is no such thing as file-name-extensions, on Unix).
– ctrl-alt-delor
Dec 11 at 15:54
add a comment |
I think mac hasbashshell (same as Gnu/Linux), but by default not all gnu tools (some are bsd). Yourfindfinds files ending.py(there is no such thing as file-name-extensions, on Unix).
– ctrl-alt-delor
Dec 11 at 15:54
I think mac has
bash shell (same as Gnu/Linux), but by default not all gnu tools (some are bsd). Your find finds files ending .py (there is no such thing as file-name-extensions, on Unix).– ctrl-alt-delor
Dec 11 at 15:54
I think mac has
bash shell (same as Gnu/Linux), but by default not all gnu tools (some are bsd). Your find finds files ending .py (there is no such thing as file-name-extensions, on Unix).– ctrl-alt-delor
Dec 11 at 15:54
add a comment |
To look for the string needle in a bunch of Python files in a haystack directory:
$ grep -l 'needle' haystack/*.py
To descend into a directory tree, you could either use grep -R or switch to iterating via find as in the answer from RoVo.
add a comment |
To look for the string needle in a bunch of Python files in a haystack directory:
$ grep -l 'needle' haystack/*.py
To descend into a directory tree, you could either use grep -R or switch to iterating via find as in the answer from RoVo.
add a comment |
To look for the string needle in a bunch of Python files in a haystack directory:
$ grep -l 'needle' haystack/*.py
To descend into a directory tree, you could either use grep -R or switch to iterating via find as in the answer from RoVo.
To look for the string needle in a bunch of Python files in a haystack directory:
$ grep -l 'needle' haystack/*.py
To descend into a directory tree, you could either use grep -R or switch to iterating via find as in the answer from RoVo.
answered Dec 11 at 15:36
DopeGhoti
43.1k55382
43.1k55382
add a comment |
add a comment |