I want to search for a pattern and append to that in a file.
To be precise here is an example of my pattern and there are hundreds in a file.
<size>30</size> needs to be replaced with <size>30,-1</size>
But the number in place of 30 is a variable (it can be any number from 0-99)
I am new to sed but I have used sed with known patterns but dont know how to modify when there is a variable in the pattern.
also I saw a sample where the code is placed in .sed file
for example: sed replace.sed datafile.xyz > new.xyz
how do I achieve that?
Thanks
With
sedyou can store part of the matched text with parentheses and include it in the replacement:http://www.grymoire.com/Unix/Sed.html#uh-4
So, for example: