I'm trying to capitalize every word that starts with "/" while ignoring the same word that doesn't start with "/" using sed. So for example, if the output has
word1
/word1
I want to leave the first word1 untouched and capitalize the second word1 to become
word1
/WORD1
If the file has multiple word1 in the same line, I want it to capitalize the last instance of word1 so
word1 /word1 /word1
would become
word1 /word1 /WORD1
I have tried sed 's/word1/\U&/'
but it simply capitalizes the every word1 in the file and I'm not quite sure how to include "/" in the search string as it would just throw an error if I add it straight on.