# shell script extended usage...

**URL:** <https://community.unix.com/t/shell-script-extended-usage/174882>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [August 24, 2007, 7:11am UTC](https://community.unix.com/t/shell-script-extended-usage/174882 "2007-08-24T07:11:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joerg535](https://community.unix.com/letter_avatar/joerg535/32/5_5575768a8748004e209b776fc1b2916d.png) [@joerg535](https://community.unix.com/u/joerg535)\
**Post date:** [August 24, 2007, 7:11am UTC](https://community.unix.com/t/shell-script-extended-usage/174882/1 "2007-08-24T07:11:12Z")

</div>

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 🙂

Thanks a lot in advance,

Joerg

---

<div class="post-metadata">

**Author:** ![funksen](https://community.unix.com/letter_avatar/funksen/32/5_5575768a8748004e209b776fc1b2916d.png) [@funksen](https://community.unix.com/u/funksen)\
**Post date:** [August 24, 2007, 10:02am UTC](https://community.unix.com/t/shell-script-extended-usage/174882/2 "2007-08-24T10:02:25Z")

</div>

```nohighlight
#!/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
