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/ ?

janos
  • 808
  • 1
  • 6
  • 22
bro
  • 191
  • 8
  • Have you tried adding the -a flag to your ls command to show 'hidden' files? Your filenames all begin with a dot. –  Aug 29 '14 at 20:31

1 Answers1

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
kasperd
  • 30,455
  • 17
  • 76
  • 124
janos
  • 808
  • 1
  • 6
  • 22