Tag: append

sed replace append character match pattern case insensitive

Problem:
replace Date to _Date in text in file:

 <xs:attribute name="Date" type="xs:date" />

to get:

<xs:attribute name="_Date" type="xs:date" />

Solution:
sed -i 's/name="\(Date\)"/name="_\1"/gI' file
t=date && sed -i "s/name=\"\($t\)\"/name=\"_\1\"/gI" file

where:
gI means replace globally case insensitive
\1 means matched date within: name=”Date”

Advertisements