Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 971
Mahakaal Avatar asked Apr 26 '11 14:04

Mahakaal


People also ask

How can regex be used for document searching?

A regular expression is a form of advanced searching that looks for specific patterns, as opposed to certain terms and phrases. With RegEx you can use pattern matching to search for particular strings of characters rather than constructing multiple, literal search queries.


1 Answers

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' 
like image 79
John Kugelman Avatar answered Sep 25 '22 23:09

John Kugelman