Use sed for Mixed Case Tags


New Member
I'm trying to reformat tags in an xlm file with using gnu sed on win10 (shoot me). I need to escape some windows command-line characters with ^.

Sample line:
<trn:description>V7906 03/11 ALFREDOCAMEL CHATSWOOD 74564500125</trn:description>

I'm not totally clear what this line does but it extracts the lines I want to edit in-place:
sed -n 's+^<trn:description^>\(.*\)^</trn:description^>$+\1+p' sourcefile

This command changes to Title Case:
sed 's/.*/\L^&/; s/\w*/\u^&/g' sourcefile

Can I bring this together as a one-liner to edit the original sourcefile in-place?

I'm aware I should use a tool like xmlstarlet but I want to use sed.

Members online