Well, what I am doing is getting the disk size, and then setting it to a variable "$SIZE". Would the extra space work in that case?
Here is the code:
## Find your disk sizes available for use.
for i in `vxdisk -o alldgs list | grep -v -e DEVICE -e LVM -e invalid -e dg | awk '{print $1}'`
do
grep $i inq.fil | grep $DISKTYPE | awk -F ":" '{print $11}'
done | uniq -d > sizes.txt
TOTAL=`cat sizes.txt | wc -l`
if [ $TOTAL -eq 0 ]
then
echo "There are no disks of this type available."
exit
else
continue
fi
## Present the sizes of the disks available.
print "Disk sizes that are available are:"
for i in `cat sizes.txt`
do
echo $i
done
## Choose what size disk(s) you want to use.
echo "What size disk do you want to use?"
print -n "Disk size? :"
read SIZE
## Capture the disk size you chose for use later.
echo $SIZE > sizes.size
function avail_disk_func
{
## Capture only the available disks of the type and size you want to use.
grep $DISKTYPE inq.fil | grep -v Copyright | grep $SIZE > $SIZE.txt
for i in `vxdisk -o alldgs list | grep -v -e DEVICE -e LVM -e invalid -e dg | awk '{print $1}'`
do
grep $i $SIZE.txt | grep $DISKTYPE | grep $SIZE
done > vxdisk_avail_$SIZE.txt
}
avail_disk_func
## Capture how many disks are available for use. If none, then exit.
TOTAL2=`cat vxdisk_avail_$SIZE.txt | wc -l`
if [ $TOTAL2 -eq 0 ]
then
echo "There are $TOTAL2 $DISKTYPE disks of this size available."
exit
else
continue
fi
echo
## How many disks do you want to use?
echo "There are $TOTAL2 $DISKTYPE disks of this size available."
echo
echo "How many do you want to use?"
print -n "to create your diskgroup? :"
read NUMBER
Here is what the inq.fil file read from at the beginning of the code looks like:
This script is only to be used when building NEW DISK GROUPS ONLY!!
that will be using VXVM 4.1 or higher to manage disks, with no rootdg.
This version has an option for striping, and lets you build multiple volumes
within the disk group(s) you create.
Have you ran the inq script?
Enter 'y' for Yes or 'n' for No :y
Chose the type of external storage
you will be working with. Your choices
are 'EMC' and 'EVA' (EVA = HSV).
Enter 'EMC' or 'EVA'. Disk type? :eva
Disk sizes that are available are:
524288000 <-- There are 11 of these
5242880 <-- There are 3 of these
What size disk do you want to use?
Disk size? :5242880 <-- This is the size I want. There are only 3
There are 14 HSV disks of this size available. <--Incorrect number reported.
How many do you want to use?
to create your diskgroup? :
Rather than my trying to re-create your scenario, you are determining the number of each disk size from "vxdisk_avail_$SIZE.txt".
Can you post this file from your run? My thinking is to do something with a cut based on -d":" and then a numeric comparison.
But, I cannot work through all of the logic in my head.
All it appears that you need is the device size, not the rest of the data when reporting number in that size category. So, I made sample1 and sample2 from your two files. I then ran the following script:
> cat numcomp
#! /bin/bash
cknum=5242880
count=0
echo $cknum
cat sample1 sample2 >sample3
cat sample3 | cut -d":" -f11 >sample4
echo "TRIAL #1"
cat sample4 | grep $cknum
echo "TRIAL #2"
cat sample4 | grep $cknum >sample5
while read zf
do
# echo $zf
if [ $zf -eq $cknum ]
then
echo "Match "$zf
count=$(($count + 1))
else
echo "Skipping "$zf
fi
done <sample5
echo $count" occurences found of "$cknum
It generated output as follows:
So, pulling out to only have the size on each line allows through script to do the mathematical match to the number. While you already have another approach to solve the matter, I thought I'd follow-up and present this programming solution. A lot of the code could be eliminated when actually used, I just wanted to show the thought process.