grep a variable

Hi all,
I am trying to do a simple thing in my mind. However I am fairly new to bash. What I need to do is create a folder for each partition on each CD, and each partition has a unique name (with spaces in it, do not ask why, it is already done :confused: ) . All CD's will show up under disk1s. So what I have done is create a script that will grab the name, assuming that there is only 1 partition (which I never knew anyone would create partitions on a CD).

So my script write now is

if [-z `diskutil list | grep disk1s0 | awk '{print$3}' ] ; then
Name = `diskutil list | grep disk1s1s2 | awk '{print$3}'
T1 = "Mass"
if[$T1 = $Name]; then
echo `diskutil list | grep disk1s1s2 | awk '{print$3 " " $4}'
else
echo `diskutil list | grep disk1s1s2 | awk '{print$3}'
fi
else
echo `diskutil list | grep disk1s0 | awk '{print$3}'
fi

what I need to add is if the disk1s1s2 name starts with Mass is I need it to look at the name of possibily multiple partitions
echo `diskutil list | grep disk1s1s2 | awk '{print$3 " " $4}'
echo `diskutil list | grep disk1s2s2 | awk '{print$3 " " $4}'
echo `diskutil list | grep disk1s3s2 | awk '{print$3 " " $4}'
echo `diskutil list | grep disk1s4s2 | awk '{print$3 " " $4}'
echo `diskutil list | grep disk1s5s2 | awk '{print$3 " " $4}'
and so on, I have seen at least 10, but there could be more, and could be less.
How would I script for this? Any help would be great.

Thanks,
Steven Stuart

Hi all,
now all I need is to make my while loop to work, which might be syntax.

  So I have 

i=1
while[-n `diskutil list | grep disk1s"$i"s2 | awk '{print$3}' ]; do
echo `diskutil list | grep disk1s"$i"s2 | awk '{print$3 " " $4}'
i+=1
done

If I remove the while loop portion just keeping the i= and the echo line it works perfectly, If I make the i=2 and so forth it works perfectly, so I know that my while loop is not correct.

Thanks,
Steven Stuart

I created a new variable and different syntax was needed

i=1
next=`diskutil list | grep disk1s"$i"s2 | awk '{print$3}'
while[ $next = $T1 ]
do
echo `diskutil list | grep disk1s"$i"s2 | awk '{print$3 " " $4}'
i=$(( $i + 1 ))
next=`diskutil list | grep disk1s"$i"s2 | awk '{print$3}'

done

Now I get the correct results that I wanted. The section above gets placed in place of the original

echo `diskutil list | grep disk1s1s2 | awk '{print$3 " " $4}'

line

Thanks,
Steven Stuart