1

How do I match only file names in an unordered file with grep?

I tried grep -Po '[a-zA-Z1-9/_-]{1,}\.php' ( I am trying to match php files), but that doesn't work for e.g http://www.google.com/index.php, because it matches com/index.php. It also needs to catch things like /directory/subdirectory/index.php

0
((https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6}))?([^\s]+\.php)

example:

my text http://www.google.com/index.php /bla.php my end

result: "http://www.google.com/index.php" and "/bla.php"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.