Suppose, I want to search for files having python in filename in it, in all sub directories of linux, from a shell script. How can I search in all locations using regex?
假设,我想搜索文件中有python的文件,在linux的所有子目录中,从一个shell脚本中。如何使用regex在所有位置搜索?
4 个解决方案
#1
74
Find all .py files.
找到所有. py文件。
find / -name '*.py'
Find files with the word "python" in the name.
在名称中找到带有“python”一词的文件。
find / -name '*python*'
Same as above but case-insensitive.
和上面一样,但不区分大小写。
find / -iname '*python*'
Regex match, more flexible. Find both .py files and files with the word "python" in the name.
正则表达式匹配,更加灵活。找到名称中带有“python”字样的.py文件和文件。
find / -regex '.*python.*\|.*\.py'
#2
0
find / -name "python"
[filler text to meet min.]
[满足最小的填充文本]
#4
0
If simple shell regexps will suffice, then you can use find
如果简单的shell regexp就足够了,那么可以使用find
find /linux -name "*python*"
Otherwise, I'd say use ack (http://betterthangrep.com/)
否则,使用ack (http://betterthangrep.com/)
#1
74
Find all .py files.
找到所有. py文件。
find / -name '*.py'
Find files with the word "python" in the name.
在名称中找到带有“python”一词的文件。
find / -name '*python*'
Same as above but case-insensitive.
和上面一样,但不区分大小写。
find / -iname '*python*'
Regex match, more flexible. Find both .py files and files with the word "python" in the name.
正则表达式匹配,更加灵活。找到名称中带有“python”字样的.py文件和文件。
find / -regex '.*python.*\|.*\.py'
#2
0
find / -name "python"
[filler text to meet min.]
[满足最小的填充文本]
#3
#4
0
If simple shell regexps will suffice, then you can use find
如果简单的shell regexp就足够了,那么可以使用find
find /linux -name "*python*"
Otherwise, I'd say use ack (http://betterthangrep.com/)
否则,使用ack (http://betterthangrep.com/)