I have a large text file with multiple occurrences of a tag containing a URL:
I need to reformat the tags as follows:
(capture just the part of the url after 'link' (the 'id') and modify the tag to 'new-tag':
- There can be multiple tags per line;
- The tag locations are not uniform - they are found in random positions throughout the file;
- The tag content can have a space at the start (' http'), use 'http://" or 'https://' and sometimes use 'www';
The tag occasionally has content or space at the end (after the 'id') such as follows:
There are sometimes occurrences of '[tag]' on their own (without the closing [/tag] or 'http') that need to be ignored.
How can I do this with sed or alternatives?