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?
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.
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 you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With