开发者

How search for files using regex in linux shell script [closed]

开发者 https://www.devze.com 2023-03-01 06:50 出处:网络
Closed. This question is off-topic. It is not currently accepting answers. 开发者_Go百科Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed. This question is off-topic. It is not currently accepting answers.
开发者_Go百科

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 10 years ago.

Improve this question

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?


Find all .py files.

find / -name '*.py'

Find files with the word "python" in the name.

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.

find / -regex '.*python.*\|.*\.py'


If simple shell regexps will suffice, then you can use find

find /linux -name "*python*"

Otherwise, I'd say use ack (http://betterthangrep.com/)


find / -name "python"

[filler text to meet min.]

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号