I search a tool(chain) (sed/bash/…) in Linux, to achieve the following: Go through a text file (here: XML) find same values, check these values for some rule and correct these values by adding an offset.
A example would be:
<!--Origin.txt-->
<Tree>
<Node foo="600" bar="50" />
<Node foo="-300" bar="600" />
</Tree>
I now wan’t to ignore bar completely, but check if e.g. foo is smaller than zero. If it is, add 1000 to foo. If not, leave it.
<!--Output.txt-->
<Tree>
<Node foo="600" bar="50" />
<Node foo="700" bar="600" />
</Tree>
I could write a small python/java program, but I bet there is a faster bash/sed/… script to do this 😉
open your file with vim, then type:
it should do the job 4 u.
EDIT
awk oneliner works for your new requirement.
in above oneliner, the criteria is the foo attribute value
<100.you can add criterias as you wish. like(x[2]>100 && x[2]<700)