file content
<page width="595.28000000" height="841.89000000">
<background type="pdf" pageno="61"/>
<layer/>
</page>
<page width="595.28000000" height="841.89000000">
<background type="pdf" pageno="62"/>
<layer/>
</page>
<page width="595.28000000" height="841.89000000">
<background type="pdf" pageno="63"/>
<layer/>
I am trying to replace e.g. pageno="62" with pageno="65" and also subsequent page nos i.e. 63->64, 64->65. I am using bash to do this. The file is very big about 930 pages so sed is slow, is there any fast way to do this?
My script
total=$(grep pageno= "$1" | tail -n1 | cut -d'"' -f4)
from="${2}"
to="${3}"
for i in $(eval "echo {${from}..${total}}")
do
sed -i "s#pageno=\"${i}\"#pageno=\"${to}_new\"#g" "${1}"
((to += 1))
done
_new
will prevent two occurences of same page no, I will delete it later on.