1

I am chrooted and running out of drive space, so I mounted back to the host drive which has plenty of space but cannot seem to redirect the outputted data to my empty drive

[root@localhost rra]# ls /mnt/maindrv/
cacti-0.8.8b  cacti-0.8.8b.tar.gz  cacti2.tar  cactidb
[root@localhost rra]# for i in `ls *.rrd`; do rrdtool dump $i > '/mnt/maindrv/'.$i.'xml'; done
[root@localhost rra]# ls /mnt/maindrv/
cacti-0.8.8b  cacti-0.8.8b.tar.gz  cacti2.tar  cactidb
[root@localhost rra]# df -h /mnt/maindrv/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/centos-home
                       97G  1.5G   96G   2% /mnt/maindrv

How do I properly output my dump to /mnt/maindrv/ ?

1
  • Have you tried adding the -a flag to your ls command to show 'hidden' files? Your filenames all begin with a dot.
    – user143703
    Aug 29, 2014 at 20:31

1 Answer 1

1

It seems you overlooked something here:

for i in `ls *.rrd`; do rrdtool dump $i > '/mnt/maindrv/'.$i.'xml'; done

In some languages the . is used to concatenate variables, but in Bash it's a literal dot. So for example if you have a file hello.rrd, then the command will put the dump in:

/mnt/maindrv/.hello.rrd.xml

Since the file starts with a dot, ls /mnt/maindrv/ will not list it, even though it's there.

Another thing, you shouldn't loop over ls *.rrd but simply *.rrd. This is not related to your question, but a bad practice.

This should do what you need, cleaner and better:

for i in *.rrd; do rrdtool dump "$i" > "/mnt/maindrv/$i.xml"; done
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .