A friend had a fun problem: she had some XML files she needed to
import into GNUcash, but the program that produced them left
names in all-caps and she wanted them more readable. So she'd
have a file like this: <STMTTRN> <TRNTYPE>DEBIT
<DTPOSTED>20111125000000[-5:EST] <TRNAMT>-22.71 <FITID>****
<NAME>SOME COMPANY <MEMO>SOME COMPANY ANY TOWN CA 11-25-11
330346 </STMTTRN>and wanted to change the NAME and MEMO lines to
read Some Company and Any Town. However, the tags, like <NAME>,
all had to remain upper case, and presumably so did strings like
DEBIT. How do you change just the NAME and MEMO lines from upper
case to title case? The obvious candidate to do string
substitutes is sed. But there are several components to the
problem. First, how do you ensure the replacement only happens
on lines with NAME and MEMO? sed lets you specify address ranges
for just that purpose. If you say sed 's/xxx/yyy/' sed will
change all xxx's to yyy; but if you say then sed will only do
that substitution on lines containing NAME. B