I want to extract the url from a string with shell/bash script, if there is more than one url in the string, then only the first one should be returned.
I have provided some examples of input and output string below. I'm guessing I would need to do some regex, but I'm not too familiar on how I would do this in bash/shell?
Input: Take a look at this site: http://www.google.com/ and you'll find your answer
Output: http://www.google.com/
Input: http://www.google.com
Output: http://www.google.com
Input: Check out http://www.bing.com and http://www.google.com
Output: http://www.bing.com
Input: Grettings, visit <http://www.mywebsite.com> today!
Output: http://www.mywebsite.com