I am trying to write a script. I use a remote procedure call with xmlrpc to get a url. I assign the output as a variable all in one command like url=$(xmlrpc 192.168.1.1 command...) for example. This is the output of the procedure call when output to a file:
Result:
String: 'http://example.url'
It all shows up on one line with echo $url. When I try to extract the URL between the single quotes with sed s/^.*'\(.*\)'.*$/\1/ $url I get the following:
sed: can't read Result:: no such file or directory
sed: can't read String:: no such file or directory
sed: can't read http://example.url: no such file or directory
Maybe the multiple lines is the problem. I get a similar error with grep -oP "(?<=').*?(?=')" $url Any ideas? I just want to extract the URL.
sed -n "s/^.*'\(.*\)'.*$/\1/ p" <<< ${url}
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