Ste*_* B. 23
find DIRECTORY -name "*.py" | xargs grep PATTERN
Run Code Online (Sandbox Code Playgroud)
顺便说一句,因为写这个,我发现ACK,这是一个更好的解决方案.
(自那次编辑以来,我发现了ag).
mon*_*ker 16
grep -r -n "PATTERN" --include="*.py" DIRECTORY
Run Code Online (Sandbox Code Playgroud)
这些天我也经常使用ack.我做了一点调整以找到所有相关的文件类型:
# Add zcml to the xml type:
--type-add
xml=.zcml
# Add more files the plone type:
--type-add
plone=.dtml,.zpt,.kss,.vpy,.props
# buildout config files
--type-set
buildout=.cfg
# Include our page templates to the html type so we can limit our search:
--type-add
html=.pt,.zpt
# Create txt file type:
--type-set
txt=.txt,.rst
# Define i18n file types:
--type-set
i18n=.pot,.po
# More options
--follow
--ignore-case
--nogroup
Run Code Online (Sandbox Code Playgroud)
重要的是要记住,如果扩展名不在其配置中,ack将无法找到文件.有关所有可用类型,请参阅"ack --help-types".
我还假设你正在使用煎蛋,所以你可以grep/ack /找到所有相关的文件?
| 归档时间: |
|
| 查看次数: |
9096 次 |
| 最近记录: |