#!/bin/bash
Drive=hda
#sets the counter that will be stuck on the end of a variable
partcounter=0
# Grabs how many partitions were setup and puts it into an array
partition=(`sfdisk -l /dev/${Drive} | grep ^/dev | cut -d" " -f1 | sed 's|/dev/||' | tr "\n" " "`)
#test output relavent to this script
# ${#array[*]} outputs the number of variables in the array
echo "${Drive} has ${#partition[@]} partitions:"
# This will output all variables in the array
echo "${partition[@]}"
# This is another way to output all variables in an array, and may or may not be more useful to you
tmpCounter=0
while [ "$tmpCounter" -lt ${#partition[*]} ]; do
echo $tmpCounter : ${partition[tmpCounter]}
tmpCounter=$(expr $tmpCounter + 1)
done