sed
would seem to be the right task for this:
% sed -n 's/.* \(iwantthis\) .* \(url=[^ ]*\) .*/\1 \2/p' url.txt
iwantthis url=https://www.google.com
iwantthis url=yahoo.com
How this works:
-n
-- only print lines that match with a "p" command
s/.../p
-- search and replace, printing lines that match
.* \(iwantthis\) .* \(url=[^ ]*\) .*
-- This will look for the word "iwantthis" surrounded by spaces and remember it, and also look for "url=" followed by non-spaces, and rememeber that. The .*
at each end mean that stuff before "iwantthis" and stuff after the URL are discarded.
/\1 \2
-- Replace it with the two remembered words