Home > Mobile >  How to export many rrd files to xml files
How to export many rrd files to xml files

Time:05-20

I have set of old rrd files, so I need to convert them to xml files and again to rrd files in a new server. In order to create xml files from whole directory, I have used following simple bash script.

#!/bin/bash

cd /varcacti/rra


for i in ./traffic_in*;
do
/usr/local/rrdtool/bin/rrdtool dump $i /home/newuser/rrd_dump_xml/$i.xml;
done

This provides a set of xml files but the extension is not what I required actually. This provides,

traffic_in_1111.rrd>>>traffic_in_1111.rrd.xml

But I need traffic_in_1111.rrd>>>traffic_in_1111.xml. can someone help me to modify my code?

CodePudding user response:

You want

/home/newuser/rrd_dump_xml/"${i%.rrd}".xml
#..........................^^^^^^^^^^^

which removes the rrd extension from the end of the string.

You might want to be more specific with the files you're looping over:

for i in ./traffic_in*.rrd
  • Related