For example, I have a huge HTML file that contains img URL: http://ex.example.com/hIh39j+ud9wr4/Uusfh.jpeg
I want to get this URL, assuming it’s the only url in the entire file.
cat file.html | grep -o 'http://ex[a-zA-Z.-]*/[a-zA-Z.-]*/[a-zA-Z.,-]*'
This works only if the URL doesn’t have the plus signs.
How do I make work for + signs as well?
You missed the character class
0-9(also useless use of cat):Slight improvement, use
-ifor case insensitivity and only match images.jpgor.jpeg.Or how about just: