1
2
Need to change values 1 and 2 from bash
Since you give a sed example in one of the comments, I imagine you want a pure bash solution?
while read input; do
for field in tag tag1; do
case $input in
*"<$field>"*"$field>"* )
pre=${input#*"<$field>"}
suf=${input%"$field>"*}
# Where are we supposed to be getting the replacement text from?
input="${input%$pre}SOMETHING${input#$suf}"
;;
esac
done
echo "$input"
done
This is completely unintelligent, and obviously only works on well-formed input with the start tag and the end tag on the same line, you can't have multiple instances of the same tag on the same line, the list of tags to substitute is hard-coded, etc.
I cannot imagine a situation where this would be actually useful, and preferable to either a script or a proper XML approach.