shell script extended usage...

Hi all,

In a shell script, how can I do the following:

Find out the size of a mounted usb stick (df -h /media/usbdisk) and use the
result (physical size of USB stick) to set a loop-counter according to the disk size??

As a result, I do copy files of 4MB each as many times as they will fit on the usb-stick. So I can use a stick of any size...
--> I need to divide the diskspace by filsize - that's clear to me :slight_smile:

Thanks a lot in advance,

Joerg

#!/usr/bin/ksh
count=$(($(df -m /media/usbstick | awk '/usbstick/{print $2}') / 4 ))
while [ $count -gt 0 ]
 do
  count=$(($count - 1))

  <yourcopystatement>

 done

the awk statement depends on your os
if you want the script for your system post the output of df -m or df -k if df -m is not available