I'm trying to remove duplicates words in a string using sed from MacOS using the following command:
sed -r 's/^([A-Za-z0-9_]+) \1$/\1/' <<< 'The best of of The United Kingdom'
But it only returns
The best of of United Kingdom
What I'm missing? Could you guys give me hand? Please.
You can try this
sedYour original code had unneeded anchors
^|$. Here is a fixed version