I have in a large xml file some hundred svg graphs where I want to change the <svg:g transform=matrix(1 0 0 1 59.06 88.74)>88.74 to 98.74 i.e to add 10 to every line that starts with <svg:g transform=matrix(How can one achieve this task without much handwork? I know of substitutions, but additions have escaped my attention.
Add 10 to a value in large xml file
text processing;scripting
My answer with awk:awk -F'[ )>]' '/\<svg\:g transform\=\matrix\(/ {sub($(NF-3), 10+$(NF-3))}1' infile > outfileawk command with -F option define space ,,) and > as field separators. then search for line that contains pattern <svg:g transform=matrix(. next pickup field $(NF-3) and replace it with 10 value added to that.$(NF) -> last > , $(NF-1) -> is last  , $(NF-2) -> is last ) and finally $(NF-3) -> is my desired value that wants to add +10 value.<svg:g transform=matrix(1 0 0 1 59.06  88.74    )              >                                       $(NF-3) $(NF-2) $(NF-1) $(NF)Input:<svg:g transform=matrix(1 0 0 1 59.06 4.74)><svg:g transform=matrix(1 0 0 1 59.06 88.74)><svg:g transform=matrix(1 0 0 1 59.06 5.74)>Output:<svg:g transform=matrix(1 0 0 1 59.06 14.74)><svg:g transform=matrix(1 0 0 1 59.06 98.74)><svg:g transform=matrix(1 0 0 1 59.06 15.74)>