Question

I wanted to use grep to show only the URL's in a text file. I have tried to use:

grep "http://www\.[[:alpha:]]\.[[:alpha:]]"

I didn't get any results although there are URL's in the text file.

Also, how can i make it works for HTTPS also??

Thanks!

Was it helpful?

Solution

You need to use the + modifier here meaning the preceding item will be matched one or more times.

grep 'http://www\.[[:alpha:]]\+\.[[:alpha:]]\+' file
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top