Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- # Author: Nyle Davis Created 14-06-04
- # Purpose: Get Size of any/all USB Flash drives.
- # Return: VAR containing 1.) Drive Name, 2.) Drive Size
- # 3.) Space Available, 4.) Mount Point
- # File: drive-size.sh
- # Parse the /sys/block for Drive location and set VAR SDDRV
- # for f in /sys/block/*/removable;
- for f in /sys/block/sd[cdef]/removable;
- do [ "$(cat $f)" = "1" ];
- echo "DRV => " $(basename $(dirname $f));
- SDDRV=$(basename $(dirname $f));
- echo "SDDRV => " ${SDDRV};
- # Parse the FDISK cmd for Drive Name and Size using ${SDDRV}
- FD="`fdisk -l | grep -i disk | grep -i ${SDDRV}`";
- echo "FD => " ${FD};
- # Set DVSZ size
- # Parse the DF cmd for the Drive available space and mount point using ${SDDRV}
- DI="`df -h | grep -i ${SDDRV}`";
- echo "DI => " ${DI};
- done
- # Get Flash name based on size value
- function getname {
- if [ ${DVSZ}>0.9 ]; then
- SDNAM="1Gig";
- elif [ ${DVSZ}>1.5 ]; then
- SDNAM="2Gig";
- elif [ ${DVSZ}>15 ]; then
- SDNAM="16Gig";
- elif [ ${DVSZ}>63 ]; then
- SDNAM="64Gig";
- fi
- done }
- exit 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement